<%@ page import="com.clw.weblogin.controller.HuanKuanLiuShuiController" %>
<%@ page import="java.util.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<title>主页</title>
<%@ include file="pages/global/mylinks.jsp" %>
<body>
<input type="hidden" id="departmentid" value="${user.departmentid}"/>
<input type="hidden" id="caozuoren" value="${user.caozuoren}">
<!--使用$可以直接输出Session里面的共享数据-->
<div>
    <ul style="height: 50px;text-align: center; " class="layui-nav  layui-bg-green">
        <li class="layui-nav-item ">
            <h1 style="font-size:25px">${user.department}明细表</h1>
        </li>
    </ul>
</div>
<!-- 提醒table -->
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this">提醒表</li>
        <li>所有账本</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <c:if test="${user.departmentid!=1}">
            <div  id="percentage" style="width: 100%;height: 40px ;background-color: #D9D9D9 ;text-align: center; ">
                <%--本月还款人数:${huankuanliushui.yihuanCount},本月还款率:${huankuanliushui.percentage}%--%>
            </div>
        </c:if>
        <div class="layui-tab-item layui-show " lay-filter="test" style="width: 100%;height: 45%"> <table id="tb_warning" lay-filter="tb_warning_tool"></table></div>
        <div class="layui-tab-item" style="width: 100%"> <table id="tb_data" lay-filter="tb_data_tool"></table></div>
    </div>
</div>
<%--<div style="width: 100%;height: 45% " lay-filter="test">--%>
    <%--<table id="tb_warning" lay-filter="tb_warning_tool">--%>
    <%--</table>--%>
<%--</div>--%>
<!-- 所有数据table -->
<%--<div style="width: 100%">--%>
    <%--<table id="tb_data" lay-filter="tb_data_tool"></table>--%>
<%--</div>--%>
<!-- 查看明细------>
<div style="display: none" id="chakan_div">
    <table id="tb_chakan"></table>
</div>
<div class="jiesuan_tiqian" id="tb_jiesuan_tiqian" style="margin:5%;display:none">
    <c:if test="${user.departmentid!='1'}">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="" id="tb_data_name_jiesuan_huankuan_buhuan" disabled>
                </div>
                <label class="layui-form-label">编号</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="" id="tb_data_usernumber_jiesuan_huankuan_buhuan"
                           disabled>
                </div>
            </div>
                    <input type="hidden" class="layui-input" value="" id="tb_data_book_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_phone_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_carnumber_jiesuan_huankuan_buhuan"
                           disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_daikuanmoney_jiesuan_huankuan_buhuan"
                           disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_daikuantype_jiesuan_huankuan_buhuan"
                           disabled>
            <input type="hidden" class="layui-input" value="" id="tb_data_daikuanbegindate_jiesuan_huankuan_buhuan"
            disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_daikuanenddate_jiesuan_huankuan_buhuan"
                           disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_lilv_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_yuegong_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_shoufu_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_yue_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_danbao_jiesuan_huankuan_buhuan" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_beizhu_jiesuan_huankuan_buhuan" disabled>
            <div class="layui-form-item">
                <label class="layui-form-label">车队</label>
                <div class="layui-input-inline" lay-filter="test2" disabled>
                    <select id="department_select_jiesuan_buhuan">
                        <option value="">请选择</option>
                    </select>
                </div>
                <label class="layui-form-label">实还金额</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="" id="tb_data_shihuanjine_jiesuan_huankuan">
                </div>
                    <input type="hidden" class="layui-input" value="" id="tb_data_lixi_jiesuan_huankuan_buhuan" disabled>
            </div>
                    <input type="hidden" class="layui-input" value=""
                           id="tb_data_lastjiebendate_jiesuan_huankuan_buhuan" placeholder="上次还本时间" disabled>
                    <input type="hidden" class="layui-input" value=""
                           id="tb_data_lastjiexidate_jiesuan_huankuan_buhuan" placeholder="上次还息时间" disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_yuhuanlixi_jiesuan_huankuan_buhuan"
                           disabled>
                    <input type="hidden" class="layui-input" value="" id="tb_data_yuhuanbenjin_jiesuan_huankuan_buhuan"
                           disabled>
            <div class="layui-form-item">
                <label class="layui-form-label">还款日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="" id="tb_data_shihuandate_jiesuan_huankuan">
                </div>
            </div>
        </form>
    </c:if>
</div>
<!-- 结算 弹出层start----------------------------------------------------------------------------------->
<div class="jiesuan_dic" style="margin:5%;display:none" id="tb_jiesuan">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" style="background-color: #D9D9D9" value=""
                               id="tb_data_name_jiesuan" disabled>
                    </div>
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" style="background-color: #D9D9D9"
                               id="tb_data_usernumber_jiesuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账本</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" style="background-color: #D9D9D9"
                               id="tb_data_book_jiesuan" disabled>
                    </div>
                    <label class="layui-form-label">存款金额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" style="background-color: #D9D9D9"
                               id="tb_data_cunkuanmoney_jiesuan" disabled>
                        <input type="hidden" class="layui-input" value="" id="tb_data_phone_jiesuan">
                        <input type="hidden" class="layui-input" value="" id="tb_data_bankcardnumber_jiesuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">开始日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_begindate_jiesuan"
                               style="background-color: #D9D9D9" disabled>
                    </div>
                    <label class="layui-form-label">结束日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_jiesuandate_jiesuan"
                               style="background-color: #D9D9D9" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">利率</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_lilv_jiesuan"
                               style="background-color: #D9D9D9" disabled>
                    </div>
                    <label class="layui-form-label">结算周期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_jiesuanzhouqi_jiesuan"
                               placeholder="单位：天" style="background-color: #D9D9D9" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上次结算</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_enddate_jiesuan"
                               style="background-color: #D9D9D9" disabled>
                    </div>
                    <label class="layui-form-label">结算时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_nowenddate_jiesuan"
                        >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">天数</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_tianshu_jiesuan"
                               style="background-color: #D9D9D9" disabled>
                    </div>
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_beizhu_jiesuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">利息</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_lixi_jiesuan">
                        <input type="hidden" class="layui-input" value="" id="tb_data_cunkuantype_jiesuan">
                    </div>
                </div>
            </form>
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_name_jiesuan_huankuan" disabled>
                    </div>
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_usernumber_jiesuan_huankuan"
                               disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账本</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_book_jiesuan_huankuan" disabled>
                    </div>
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_phone_jiesuan_huankuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车牌照</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_carnumber_jiesuan_huankuan"
                               disabled>
                    </div>
                    <label class="layui-form-label">贷款金额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_daikuanmoney_jiesuan_huankuan"
                               disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">贷款类型</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_daikuantype_jiesuan_huankuan"
                               disabled>
                    </div>
                    <label class="layui-form-label">放贷日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_daikuanbegindate_jiesuan_huankuan"
                               disabled>
                        <input type="hidden" class="layui-input" id="tb_data_daikuanenddate_jiesuan_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">利率</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_lilv_jiesuan_huankuan" disabled>
                    </div>
                    <label class="layui-form-label">月供</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_yuegong_jiesuan_huankuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">首付</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_shoufu_jiesuan_huankuan" disabled>
                    </div>
                    <label class="layui-form-label">余额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_yue_jiesuan_huankuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">担保</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_danbao_jiesuan_huankuan" disabled>
                    </div>
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_beizhu_jiesuan_huankuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车队</label>
                    <div class="layui-input-inline" lay-filter="test2" disabled>
                        <select id="department_select_jiesuan">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <label class="layui-form-label">拖欠利息</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_lixi_jiesuan_huankuan" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上次还本时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value=""
                               id="tb_data_lastjiebendate_jiesuan_huankuan" placeholder="上次还本时间" disabled>
                    </div>
                    <label class="layui-form-label">上次还息时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value=""
                               id="tb_data_lastjiexidate_jiesuan_huankuan" placeholder="上次还息时间" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应还利息</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_yuhuanlixi_jiesuan_huankuan"
                               disabled>
                    </div>
                    <label class="layui-form-label">实还利息</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_shihuanlixi_jiesuan_huankuan"
                               disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">应还本金</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_yuhuanbenjin_jiesuan_huankuan"
                               disabled>
                    </div>
                    <label class="layui-form-label">实还本金</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_shihuanbenjin_jiesuan_huankuan">
                    </div>
                </div>
            </form>
        </c:when>
    </c:choose>
</div>
<!-- 结算 弹出层start----------------------------------------------------------------------------------->
<!-- add弹出层---------------------------------------start--------------------------------------------------------------------->
<div class="site-text" style="margin:5%;display:none" id="tb_data_adddiv" target="test123">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_name">
                    </div>
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_usernumber">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账本</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_book">
                    </div>
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_phone">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">银行卡号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_bankcardnumber">
                    </div>
                    <label class="layui-form-label">存款金额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_cunkuanmoney">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">开始日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_begindate">
                    </div>
                        <%--<label class="layui-form-label">预计取息</label>--%>
                        <%--<div class="layui-input-inline">--%>
                        <%--<input type="text" class="layui-input" value="" id="tb_data_adddiv_add_jiesuandate">--%>
                        <%--<input type="hidden" class="layui-input" value="" id="tb_data_adddiv_add_endddate">--%>
                        <%--</div>--%>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">利率</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_lilv">
                    </div>
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_beizhu">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">存款类型</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_cunkuantype">
                    </div>
                    <label class="layui-form-label">结算周期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_jiesuanzhouqi"
                               placeholder="单位：天">
                    </div>
                </div>
            </form>
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            <form class="layui-form layui-form-pane " id="add_huankuan_form">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_name_huankuan">
                    </div>
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_usernumber_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账本</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_book_huankuan">
                    </div>
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_phone_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车牌照</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_carnumber_huankuan">
                    </div>
                    <label class="layui-form-label">贷款金额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_daikuanmoney_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">贷款类型</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_daikuantype_huankuan">
                    </div>
                    <label class="layui-form-label">放贷日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_begindate_huankuan">
                    </div>
                        <%--<label class="layui-form-label">结束日期</label>--%>
                        <%--<div class="layui-input-inline">--%>
                    <input type="hidden" class="layui-input" value="" id="tb_data_adddiv_add_enddate_huankuan">
                        <%--</div>--%>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">利率</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_lilv_huankuan">
                    </div>
                    <label class="layui-form-label">月供</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_yuegong_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">首付</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_shoufu_huankuan">
                    </div>
                    <label class="layui-form-label">上次还息时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value=""
                               id="tb_data_adddiv_add_shangcijiexidate_huankuan" placeholder="上次结息时间">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上次还款时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value=""
                               id="tb_data_adddiv_add_shangcijiebendate_huankuan" placeholder="上次还款时间">
                    </div>
                    <label class="layui-form-label">余额</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_yue_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">担保</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_danbao_huankuan">
                    </div>
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_beizhu_huankuan">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车队</label>
                    <div class="layui-input-inline" lay-filter="test2">
                        <select id="department_select">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <label class="layui-form-label">拖欠利息</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" value="" id="tb_data_adddiv_add_lixi_huankuan">
                    </div>
                </div>
            </form>
        </c:when>
    </c:choose>
</div>
<!-- add弹出层---------------------------------------end--------------------------------------------------------------------->
<!---------------------------------------- tb_data 行操作层 start ---------------------------->
<script type="text/html" id="barDemo">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            {{# if(d.type==0){ }}
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs" lay-event="jiesuan">取息</a>
            <a class="layui-btn layui-btn-xs" lay-event="chouben">抽本</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            {{# } }}
            {{# if(d.type==1){ }}
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            {{# } }}
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            {{# if(d.type==0){ }}
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs" lay-event="huanben">还本</a>
            <a class="layui-btn layui-btn-xs" lay-event="huanxi">还息</a>
            <a class="layui-btn layui-btn-xs" lay-event="buhuan">补还</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            {{# } }}
            {{# if(d.type==1){ }}
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            {{# } }}
        </c:when>
    </c:choose>

</script>
<!---------------------------------------- tb_data 行操作层 end ---------------------------->

<!---------------------------------------- tb_waring 行操作层 start ---------------------------->
<script type="text/html" id="barDemo_waring">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            {{# if(d.type==0){ }}
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs" lay-event="jiesuan">取息</a>
            <a class="layui-btn layui-btn-xs" lay-event="chouben">抽本</a>
            {{# } }}
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs" lay-event="huanben">还本</a>
            <a class="layui-btn layui-btn-xs" lay-event="huanxi">还息</a>
        </c:when>
    </c:choose>
</script>
<!---------------------------------------- tb_waring 行操作层 end ---------------------------->
<!---------------------------------------- tb_data 表头start ---------------------------->
<script type="text/html" id="toolbarDemo">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            <div class="demoTable">
                姓名：
                <div class="layui-inline">
                    <input class="layui-input" id="tb_data_input_name" autocomplete="off">
                </div>
                编号：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_data_input_namenumber" autocomplete="off">
                </div>
                存款金额：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_data_input_cunkuanmoney" autocomplete="off">
                </div>
                存款时间：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="tb_data_input_cunkuandate" placeholder="yyyy-MM-dd">
                </div>
                状态：
                <div class="layui-input-inline">
                    <select name="type_select" lay-verify="required" lay-search="" id="type_select">
                        <option value="">请选择分类</option>
                        <option value="2">隐藏的数据</option>
                    </select>
                </div>
                <div class="layui-btn layui-btn-sm " data-type="reload" id="tb_data_sousuo" lay-event="tb_data_sousuo">
                    搜索
                </div>
            </div>
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal" lay-event="tb_data_add">添加</button>
            </div>
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            <div class="demoTable">
                姓名：
                <div class="layui-inline">
                    <input class="layui-input" id="tb_data_input_name_huankuan" autocomplete="off">
                </div>
                编号：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_data_input_namenumber_huankuan" autocomplete="off">
                </div>
                贷款金额：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_data_input_daikuanmoney_huankuan" autocomplete="off">
                </div>
                放贷时间：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="tb_data_input_daikuanbegindate_huankuan"
                           placeholder="yyyy-MM-dd">

                </div>
                <div class="layui-btn layui-btn-sm " data-type="reload" id="tb_data_sousuo_huankuan"
                     lay-event="tb_data_sousuo_huankuan">搜索
                </div>
            </div>
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal" lay-event="tb_data_add_huankuan">添加</button>
            </div>
        </c:when>
    </c:choose>
</script>
<!---------------------------------------- tb_data 表头end ---------------------------->
<!------------------------------------   tb_waring 表头start---------------------------->
<script type="text/html" id="toolbarDemo_waring">
    <c:choose>
        <c:when test="${user.departmentid=='1'}">
            <div class="demoTable">
                姓名：
                <div class="layui-inline">
                    <input class="layui-input" id="tb_waring_input_name" autocomplete="off">
                </div>
                编号：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_waring_input_namenumber" autocomplete="off">
                </div>
                存款金额：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_waring_input_cunkuanmoney" autocomplete="off">
                </div>
                存款时间：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="tb_waring_input_cunkuandate" placeholder="yyyy-MM-dd">
                </div>
                <div class="layui-btn layui-btn-sm " data-type="reload" id="tb_waring_sousuo"
                     lay-event="tb_waring_sousuo">
                    搜索
                </div>
            </div>
        </c:when>
        <c:when test="${user.departmentid!='1'}">
            <div class="demoTable">
                姓名：
                <div class="layui-inline">
                    <input class="layui-input" id="tb_waring_input_name_huankuan" autocomplete="off">
                </div>
                编号：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_waring_input_namenumber_huankuan" autocomplete="off">
                </div>
                贷款金额：
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="tb_waring_input_daikuanmoney_huankuan" autocomplete="off">
                </div>
                放贷时间：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="tb_waring_input_daikuanbegindate_huankuan"
                           placeholder="yyyy-MM-dd">
                </div>
                <div class="layui-btn layui-btn-sm " data-type="reload" id="tb_waring_sousuo_huankuan"
                     lay-event="tb_waring_sousuo_huankuan">
                    搜索
                </div>
            </div>
        </c:when>
    </c:choose>
</script>
<!------------------------------------   tb_waring 表头end---------------------------->
<script>
    //加载完成
    $(function () {
        layui.use('element', function(){
            var element = layui.element;

        });
        percentageDiv();
        var departmentid =${user.departmentid};
        tb_warning(departmentid)
        tb_data(departmentid);
        $.ajax({
            url: '${ctx}/huankuan/selectDepartment',
            type: 'get',
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    $("#department_select").append("<option value=" + data[i].departmentid + ">" + data[i].departmentname + "</option>");
                    $("#department_select_jiesuan").append("<option value=" + data[i].departmentid + ">" + data[i].departmentname + "</option>");
                    $("#department_select_jiesuan_buhuan").append("<option value=" + data[i].departmentid + ">" + data[i].departmentname + "</option>");

                }
                renderForm();//表单重新渲染，要不然添加完显示不出来新的option
            }
        });
    });
    //还款比例
    function percentageDiv(){
        $.ajax({
            url:'${ctx}/huankuanliushui/selectCount',
            type:'post',
            success:function(data){
                var data=data.data;
                percentage.innerHTML="本月还款人数:"+data.yihuanCount+",本月还款率:"+data.percentage+"%";
            }
        })
    }
    function renderForm() {
        layui.use('form', function () {
            var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
            form.render('select');
        });
    }

    //提醒表数据加载
    function tb_warning(departmentid) {
        if (departmentid == 1) {
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#tb_warning'
                    , url: "${ctx}/jiekuan/selectBydate"
                    , where: {
                        departmentid:${user.departmentid}
                    }
                    , title: "提醒表"
                    , page: true //开启分页
                    , limits: [10, 20, 100,500,1000,2000]
                    , limit: 10
                    , toolbar: '#toolbarDemo_waring'
                    , page: {
                        curr: 1
                    }
                    , cols: [[ //表头
                        {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left', totalRowText: '合计'}
                        , {field: 'name', title: '姓名', width: 90}
                        , {field: 'usernumber', title: '编号', width: 120, sort: true}
                        , {field: 'book', title: '账本', width: 100}
                        , {field: 'phone', title: '手机号', width: 120}
                        , {field: 'bankcardnumber', title: '银行卡号', width: 180}
                        , {field: 'cunkuanmoney', title: '存款金额', width: 100, sort: true}
                        , {
                            field: 'strcunkuandate', title: '存款日期', width: 120, sort: true
                        }

                        , {field: 'jiesuanzhouqi', title: '结算周期', width: 90}
                        // , {
                        //     field: 'strjiesuandate', title: '预计取息', width: 120, sort: true
                        // }
                        , {field: 'lilv', title: '利率', width: 70}
                        , {field: 'yujilixi', title: '预计利息', width: 100}

                        , {
                            field: 'strenddate', title: '付息日期', width: 125, sort: true
                        }
                        , {field: 'cunkuantype', title: '存款方式', sort: true, width: 100}
                        , {
                            field: 'shijiday', title: '天数', width: 70
                        }
                        , {
                            field: 'havelixi', title: '利息', width: 100
                        }
                        , {field: 'beizhu', title: '备注', width: 120}
                        , {field: 'caozuoren', title: '经办人', width: 100}
                        , {field: 'caozuo', title: '操作', width: 170, toolbar: '#barDemo_waring', fixed: 'right'}
                    ]]
                    , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                        return {
                            "code": res.state, //解析接口状态
                            "msg": res.message, //解析提示文本
                            "count": res.count, //解析数据长度
                            "data": res.data //解析数据列表
                        };
                    }, response: {
                        statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                    }, done: function () {
                        layui.use('laydate', function () {
                            var laydate1 = layui.laydate;
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_waring_input_cunkuandate'
                            });
                        });
                    }
                });
                //头工具栏事件
                layui.use('table', function () {
                    var table = layui.table;
                    table.on('toolbar(tb_warning_tool)', function (obj) {
                        var checkStatus = table.checkStatus(obj.config.id);
                        switch (obj.event) {
                            case 'tb_waring_sousuo':
                                //提醒表搜索----------------------------------------------start----------------------------------------------
                                var tb_waring_input_name = $("#tb_waring_input_name").val();
                                var tb_waring_input_namenumber = $("#tb_waring_input_namenumber").val();
                                var tb_waring_input_cunkuanmoney = $("#tb_waring_input_cunkuanmoney").val();
                                var tb_waring_input_cunkuandate = $("#tb_waring_input_cunkuandate").val();
                                table.reload('tb_warning', {
                                    page: {
                                        curr: 1
                                    }
                                    , where: {
                                        departmentid:${user.departmentid}
                                        , name: $("#tb_waring_input_name").val()
                                        , usernumber: $("#tb_waring_input_namenumber").val()
                                        , cunkuanmoney: $("#tb_waring_input_cunkuanmoney").val()
                                        , cunkuandate: $("#tb_waring_input_cunkuandate").val()
                                    }
                                });
                                $("#tb_waring_input_name").val(tb_waring_input_name);
                                $("#tb_waring_input_namenumber").val(tb_waring_input_namenumber);
                                $("#tb_waring_input_cunkuanmoney").val(tb_waring_input_cunkuanmoney);
                                $("#tb_waring_input_cunkuandate").val(tb_waring_input_cunkuandate);
                                //搜索----------------------------------------------end----------------------------------------------
                                break;
                            case 'isAll':
                                layer.msg(checkStatus.isAll ? '全选' : '未全选');
                                break;
                        }
                    });
                });
                //行工具事件
                layui.use('table', function () {
                    var table = layui.table;
                    table.on('tool(tb_warning_tool)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                        var data = obj.data //获得当前行数据
                            , layEvent = obj.event; //获得 lay-event 对应的值
                        if (layEvent == 'detail') {
                            selectBean(data, departmentid);
                        } else if (layEvent === 'jiesuan') {
                            jiesuan(data, departmentid, obj);
                        } else if (layEvent === 'chouben') {
                            chouben(data, departmentid, obj);
                        }
                    });
                });
            });
        } else {
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#tb_warning'
                    , url: "${ctx}/huankuan/selectBydate"
                    , where: {
                        departmentid:${user.departmentid}
                    }
                    , title: "提醒表"
                    , page: true //开启分页
                    , limits: [10, 20, 100,500,1000,2000]
                    , limit: 10
                    , toolbar: '#toolbarDemo_waring'
                    , page: {
                        curr: 1
                    }
                    , cols: [[ //表头
                        {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                        , {field: 'name', title: '姓名', width: 90}
                        , {field: 'namenumber', title: '编号', width: 120, sort: true}
                        , {field: 'book', title: '账本', width: 100}
                        , {field: 'phone', title: '手机号', width: 120}
                        , {field: 'carnumber', title: '车牌号', width: 90}
                        , {field: 'daikuantype', title: '贷款类型', width: 100}
                        , {field: 'daikuanmoney', title: '贷款金额', width: 120}
                        , {
                            field: 'strdaikuanbegindate', title: '贷款日期', width: 120, sort: true
                        }
                        , {
                            field: 'strdaikuanenddate', title: '到期日期', width: 120, sort: true
                        }
                        , {field: 'yue', title: '余额', width: 90}
                        , {field: 'lilv', title: '利率', width: 70}
                        , {
                            field: 'strjiexidate', title: '上次还息日期', width: 130, sort: true
                        }
                        , {field: 'xiday', title: '天数', width: 70}
                        , {
                            field: 'havelixi', title: '利息', width: 90, totalRow: true
                        }
                        , {field: 'strjiebendate', title: '上次还款日期', width: 130}
                        , {field: 'yuegong', title: '月供', width: 90}
                        , {field: 'shoufu', title: '首付', width: 90}
                        , {field: 'danbao', title: '担保', width: 100}
                        , {field: 'departmentname', title: '车队', width: 100}
                        , {field: 'beizhu', title: '备注', width: 100}
                        , {field: 'caozuoren', title: '经办人', width: 90}
                        , {field: 'caozuo', title: '操作', width: 170, toolbar: '#barDemo_waring', fixed: 'right'}
                    ]]
                    , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                        return {
                            "code": res.state, //解析接口状态
                            "msg": res.message, //解析提示文本
                            "count": res.count, //解析数据长度
                            "data": res.data //解析数据列表
                        };
                    }, response: {
                        statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                    }, done: function () {
                        layui.use('laydate', function () {
                            var laydate1 = layui.laydate;
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_waring_input_daikuanbegindate_huankuan'
                            });
                            laydate1.render({
                                elem: '#tb_data_shihuandate_jiesuan_huankuan'
                            });

                        });

                        LayUIDataTable.SetJqueryObj($);// 第一步：设置jQuery对象
                        var currentRowDataList = LayUIDataTable.ParseDataTable(function (index, currentData, rowData) {
                        })
                        $.each(currentRowDataList, function (index, obj) {
                            if (obj['havelixi'] && obj['havelixi'].value > 0) { //红色
                                obj['havelixi'].row.css({"background-color": "#993333", 'color': '#99CCCC'});
                            }else if (obj['yue'].value >0 && obj['havelixi'].value <= 0) { //黄色F7B940
                                obj['havelixi'].row.css({"background-color": "#DAA569", 'color': '#CCFFFF'});
                            }else if(obj['yue'].value ==0&& obj['havelixi'].value <= 0){

                            }
                        })
                    }
                });
                //头工具栏事件
                layui.use('table', function () {
                    var table = layui.table;
                    table.on('toolbar(tb_warning_tool)', function (obj) {
                        var checkStatus = table.checkStatus(obj.config.id);
                        switch (obj.event) {
                            case 'tb_waring_sousuo_huankuan':
                                //搜索----------------------------------------------start----------------------------------------------
                                var tb_waring_input_name_huankuan = $("#tb_waring_input_name_huankuan").val();
                                var tb_waring_input_namenumber_huankuan = $("#tb_waring_input_namenumber_huankuan").val();
                                var tb_waring_input_daikuanmoney_huankuan = $("#tb_waring_input_daikuanmoney_huankuan").val();
                                var tb_waring_input_daikuanbegindate_huankuan = $("#tb_waring_input_daikuanbegindate_huankuan").val();
                                table.reload('tb_warning', {
                                    page: {
                                        curr: 1
                                    }
                                    , where: {
                                        departmentid: departmentid
                                        , name: $("#tb_waring_input_name_huankuan").val()
                                        , namenumber: $("#tb_waring_input_namenumber_huankuan").val()
                                        , daikuanmoney: $("#tb_waring_input_daikuanmoney_huankuan").val()
                                        , daikuanbegindate: $("#tb_waring_input_daikuanbegindate_huankuan").val()
                                    }
                                });
                                $("#tb_waring_input_name_huankuan").val(tb_waring_input_name_huankuan);
                                $("#tb_waring_input_namenumber_huankuan").val(tb_waring_input_namenumber_huankuan);
                                $("#tb_waring_input_daikuanmoney_huankuan").val(tb_waring_input_daikuanmoney_huankuan);
                                $("#tb_waring_input_daikuanbegindate_huankuan").val(tb_waring_input_daikuanbegindate_huankuan);
                                //搜索----------------------------------------------end----------------------------------------------
                                break;
                        }
                    });
                });
                //行工具事件
                layui.use('table', function () {
                    var table = layui.table;
                    table.on('tool(tb_warning_tool)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                        var data = obj.data //获得当前行数据
                            , layEvent = obj.event; //获得 lay-event 对应的值
                        if (layEvent == 'detail') {
                            selectBean(data, departmentid);
                        } else if (layEvent === 'del') {
                            if ($("#departmentid").val() == 0) {
                                layer.alert("没有权限");
                            } else {
                                layer.confirm('真的删除么', function (index) {
                                    deleteBean(data, departmentid);
                                    obj.del(); //删除对应行（tr）的DOM结构
                                    layer.close(index);
                                    //向服务端发送删除指令
                                });
                            }
                        } else if (layEvent === 'edit') {
                            if ($("#departmentid").val() == 0) {
                                layer.alert("没有权限");
                            } else {
                                editBean(data, departmentid);
                            }
                        } else if (layEvent === 'huanben') {
                            if ($("#departmentid").val() == 0) {
                                layer.alert("没有权限");
                            } else {
                                if (data.havelixi > 0) {
                                    layer.msg('请先还利息');
                                } else {
                                    jiesuan(data, departmentid, obj);
                                }
                            }
                        } else if (layEvent === "huanxi") {
                            if ($("#departmentid").val() == 0) {
                                layer.alert("没有权限");
                            } else {
                                huanxi(data, departmentid, obj);
                            }
                        }
                    });
                });
            });
        }
    }

    //数据表加载
    function tb_data(departmentid) {
        if (departmentid == 1) {
            //借款table--------------------------------start--------------------------------
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#tb_data'
                    , url: "${ctx}/jiekuan/select"
                    , where: {
                        departmentid: departmentid
                    }
                    , toolbar: '#toolbarDemo'
                    , page: true //开启分页
                    , limits: [10, 20, 100,500,1000,2000]
                    , limit: 10
                    , page: {
                        curr: 1
                    }
                    , totalRow: true
                    , cols: [[ //表头
                        {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left', totalRowText: '合计'}
                        , {field: 'name', title: '姓名', width: 90}
                        , {field: 'usernumber', title: '编号', width: 120, sort: true}
                        , {field: 'book', title: '账本', width: 100}
                        , {field: 'phone', title: '手机号', width: 120}
                        , {field: 'bankcardnumber', title: '银行卡号', width: 180}
                        , {field: 'cunkuanmoney', title: '存款金额', width: 100, sort: true, totalRow: true}
                        , {
                            field: 'strcunkuandate', title: '存款日期', width: 120, sort: true
                        }

                        , {field: 'jiesuanzhouqi', title: '结算周期', width: 90}
                        , {
                            field: 'strjiesuandate', title: '结束日期', width: 160, sort: true
                        }
                        , {field: 'lilv', title: '利率', width: 70}
                        , {field: 'yujilixi', title: '预计利息', width: 100}

                        , {
                            field: 'strenddate', title: '付息日期', width: 125, sort: true
                        }
                        , {field: 'cunkuantype', title: '存款方式', sort: true, width: 100}
                        , {field: 'shijiday', title: '天数', width: 70}
                        , {field: 'havelixi', title: '获得利息', width: 100, totalRow: true}
                        , {field: 'beizhu', title: '备注', width: 120}
                        , {field: 'caozuoren', title: '经办人', width: 100}
                        , {field: 'caozuo', title: '操作', width: 260, toolbar: '#barDemo', fixed: 'right'}
                    ]]
                    , done: function () {
                        layui.use('laydate', function () {
                            var laydate1 = layui.laydate;
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_input_cunkuandate'
                            });
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_adddiv_add_begindate'
                            });
                            //执行一个laydate实例
                            // laydate1.render({
                            //     elem: '#tb_data_adddiv_add_jiesuandate'
                            // });
                        });
                    }
                    , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                        return {
                            "code": res.state, //解析接口状态
                            "msg": res.message, //解析提示文本
                            "count": res.count, //解析数据长度
                            "data": res.data //解析数据列表
                        };
                    }, response: {
                        statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                    }
                });
            });
            //头工具栏事件
            layui.use('table', function () {
                var table = layui.table;
                table.on('toolbar(tb_data_tool)', function (obj) {
                    var checkStatus = table.checkStatus(obj.config.id);
                    switch (obj.event) {
                        case 'aaaaaaaaaaaaaa':
                            var data = checkStatus.data;
                            layer.alert(JSON.stringify(data));
                            break;
                        case 'tb_data_add':
                            addBean($("#departmentid").val());
                            break;
                        case 'tb_data_sousuo':
                            //搜索----------------------------------------------start----------------------------------------------
                            var type = $("#type_select").val();
                            if (type != 2) {
                                type = 0;
                            }
                            var tb_data_input_name = $("#tb_data_input_name").val();
                            var tb_data_input_namenumber = $("#tb_data_input_namenumber").val();
                            var tb_data_input_cunkuanmoney = $("#tb_data_input_cunkuanmoney").val();
                            var tb_data_input_cunkuandate = $("#tb_data_input_cunkuandate").val();
                            table.reload('tb_data', {
                                page: {
                                    curr: 1
                                }
                                , where: {
                                    departmentid:${user.departmentid}
                                    , name: $("#tb_data_input_name").val()
                                    , usernumber: $("#tb_data_input_namenumber").val()
                                    , cunkuanmoney: $("#tb_data_input_cunkuanmoney").val()
                                    , cunkuandate: $("#tb_data_input_cunkuandate").val()
                                    , type: type
                                }
                            });
                            $("#tb_data_input_name").val(tb_data_input_name);
                            $("#tb_data_input_namenumber").val(tb_data_input_namenumber);
                            $("#tb_data_input_cunkuanmoney").val(tb_data_input_cunkuanmoney);
                            $("#tb_data_input_cunkuandate").val(tb_data_input_cunkuandate);
                            //搜索----------------------------------------------end----------------------------------------------
                            break;
                    }
                });
            });
            //监听行工具事件
            layui.use('table', function () {
                var table = layui.table;
                table.on('tool(tb_data_tool)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                    var data = obj.data //获得当前行数据
                        , layEvent = obj.event; //获得 lay-event 对应的值
                    if (layEvent == 'detail') {
                        selectBean(data, departmentid);
                    } else if (layEvent === 'del') {
                        layer.confirm('真的删除么', function (index) {
                            deleteBean(data, departmentid);
                            obj.del(); //删除对应行（tr）的DOM结构
                            layer.close(index);
                            //向服务端发送删除指令
                        });
                    } else if (layEvent === 'jiesuan') {
                        jiesuan(data, departmentid, obj);
                    } else if (layEvent === 'edit') {
                        editBean(data, departmentid);
                    } else if (layEvent === 'chouben') {
                        chouben(data, departmentid, obj);
                        //obj.del(); //删除对应行（tr）的DOM结构
                    }
                });
            });
            //借款table--------------------------------end--------------------------------
        }
        else {
            // 还款table--------------------------------start--------------------------------
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#tb_data'
                    , url: "${ctx}/huankuan/select"
                    , where: {
                        departmentid: departmentid
                    }
                    , toolbar: '#toolbarDemo'
                    , page: true //开启分页
                    , limits: [10, 20, 100,500,1000,2000]
                    , limit: 10
                    , page: {
                        curr: 1
                    }
                    , cols: [[ //表头
                        {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                        , {field: 'name', title: '姓名', width: 90}
                        , {field: 'namenumber', title: '编号', width: 120, sort: true}
                        , {field: 'book', title: '账本', width: 100}
                        , {field: 'phone', title: '手机号', width: 120}
                        , {field: 'carnumber', title: '车牌号', width: 90}
                        , {field: 'daikuantype', title: '贷款类型', width: 100}
                        , {field: 'daikuanmoney', title: '贷款金额', width: 120}
                        , {
                            field: 'strdaikuanbegindate', title: '贷款日期', width: 120, sort: true
                        }
                        , {
                            field: 'strdaikuanenddate', title: '到期日期', width: 120, sort: true
                        }
                        , {field: 'yue', title: '余额', width: 90}
                        , {field: 'lilv', title: '利率', width: 70}
                        , {
                            field: 'strjiexidate', title: '上次还息日期', width: 130, sort: true
                        }
                        , {field: 'xiday', title: '天数', width: 70}
                        , {
                            field: 'havelixi', title: '利息', width: 90, totalRow: true
                        }
                        , {field: 'strjiebendate', title: '上次还款日期', width: 130}
                        , {field: 'yuegong', title: '月供', width: 90}
                        , {field: 'shoufu', title: '首付', width: 90}
                        , {field: 'danbao', title: '担保', width: 100}
                        , {field: 'departmentname', title: '车队', width: 100}
                        , {field: 'beizhu', title: '备注', width: 100}
                        , {field: 'caozuoren', title: '经办人', width: 90}
                        , {field: 'caozuo', title: '操作', width: 310, toolbar: '#barDemo', fixed: 'right'}
                    ]]
                    , done: function () {
                        layui.use('laydate', function () {
                            var laydate1 = layui.laydate;
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_input_daikuanbegindate_huankuan'
                            });
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_adddiv_add_begindate_huankuan'
                            });
                            laydate1.render({
                                elem: '#tb_data_shihuandate_jiesuan_huankuan'
                            });
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_adddiv_add_enddate_huankuan'
                            });
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_adddiv_add_shangcijiexidate_huankuan'
                            });
                            //执行一个laydate实例
                            laydate1.render({
                                elem: '#tb_data_adddiv_add_shangcijiebendate_huankuan'
                            });
                        });

                        LayUIDataTable.SetJqueryObj($);// 第一步：设置jQuery对象
                        var currentRowDataList = LayUIDataTable.ParseDataTable(function (index, currentData, rowData) {
                        })
                        $.each(currentRowDataList, function (index, obj) {
                            if (obj['havelixi'] && obj['havelixi'].value > 0) { //红色
                                obj['havelixi'].row.css({"background-color": "#993333", 'color': '#99CCCC'});
                            }else if (obj['yue'].value >0 && obj['havelixi'].value <= 0) { //黄色F7B940
                                obj['havelixi'].row.css({"background-color": "#DAA569", 'color': '#CCFFFF'});
                            }else if(obj['yue'].value ==0&& obj['havelixi'].value <= 0){

                            }
                        })
                    }
                    , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                        return {
                            "code": res.state, //解析接口状态
                            "msg": res.message, //解析提示文本
                            "count": res.count, //解析数据长度
                            "data": res.data //解析数据列表
                        };
                    }, response: {
                        statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                    }
                });
            });
            //头工具栏事件
            layui.use('table', function () {
                var table = layui.table;
                table.on('toolbar(tb_data_tool)', function (obj) {
                    var checkStatus = table.checkStatus(obj.config.id);
                    switch (obj.event) {
                        case 'aaaaaaaaaaaaaa':
                            var data = checkStatus.data;
                            layer.alert(JSON.stringify(data));
                            break;
                        case 'tb_data_add_huankuan':
                            if ($("#departmentid").val() == 0) {
                                layer.alert("没有权限");
                            } else {
                                addBean($("#departmentid").val());
                            }
                            break;
                        case 'tb_data_sousuo_huankuan':
                            //搜索----------------------------------------------start----------------------------------------------
                            var tb_data_input_name_huankuan = $("#tb_data_input_name_huankuan").val();
                            var tb_data_input_namenumber_huankuan = $("#tb_data_input_namenumber_huankuan").val();
                            var tb_data_input_daikuanmoney_huankuan = $("#tb_data_input_daikuanmoney_huankuan").val();
                            var tb_data_input_daikuanbegindate_huankuan = $("#tb_data_input_daikuanbegindate_huankuan").val();
                            table.reload('tb_data', {
                                page: {
                                    curr: 1
                                }
                                , where: {
                                    departmentid: departmentid
                                    , name: $("#tb_data_input_name_huankuan").val()
                                    , namenumber: $("#tb_data_input_namenumber_huankuan").val()
                                    , daikuanmoney: $("#tb_data_input_daikuanmoney_huankuan").val()
                                    , daikuanbegindate: $("#tb_data_input_daikuanbegindate_huankuan").val()
                                }
                            });
                            $("#tb_data_input_name_huankuan").val(tb_data_input_name_huankuan);
                            $("#tb_data_input_namenumber_huankuan").val(tb_data_input_namenumber_huankuan);
                            $("#tb_data_input_daikuanmoney_huankuan").val(tb_data_input_daikuanmoney_huankuan);
                            $("#tb_data_input_daikuanbegindate_huankuan").val(tb_data_input_daikuanbegindate_huankuan);
                            //搜索----------------------------------------------end----------------------------------------------
                            break;
                        case 'isAll':
                            layer.msg(checkStatus.isAll ? '全选' : '未全选');
                            break;
                    }
                });
            });
            //监听行工具事件
            layui.use('table', function () {
                var table = layui.table;
                table.on('tool(tb_data_tool)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                    var data = obj.data //获得当前行数据
                        , layEvent = obj.event; //获得 lay-event 对应的值
                    if (layEvent == 'detail') { //查看
                        selectBean(data, departmentid);
                    } else if (layEvent === 'del') { //删除
                        if ($("#departmentid").val() == 0) {
                            layer.alert("没有权限");
                        } else {
                            layer.confirm('真的删除么', function (index) {
                                deleteBean(data, departmentid);
                                obj.del(); //删除对应行（tr）的DOM结构
                                layer.close(index);
                                //向服务端发送删除指令
                            });
                        }
                    } else if (layEvent === 'edit') {//修改
                        if ($("#departmentid").val() == 0) {
                            layer.alert("没有权限");
                        } else {
                            editBean(data, departmentid);
                        }
                    } else if (layEvent === 'huanben') { //还本
                        if ($("#departmentid").val() == 0) {
                            layer.alert("没有权限");
                        } else {
                            if (data.havelixi > 0) {
                                layer.msg('请先还利息');
                            } else {
                                jiesuan(data, departmentid, obj);
                            }
                        }
                    } else if (layEvent === "huanxi") { //还息
                        if($("#departmentid").val()==0){
                            layer.alert("没有权限");
                        }else {
                            huanxi(data, departmentid, obj);
                        }
                    } else if (layEvent === "buhuan") {
                        if($("#departmentid").val()==0){
                            layer.alert("没有权限");
                        }else {
                            buhuan(data, departmentid, obj);
                        }
                    }
                });
            });
        }
        // 还款table--------------------------------end--------------------------------
    }

    //form清空---------------------------start---------------------------
    function reload(department) {
        if (department == 1) {
            //添加清空
            $("#tb_data_adddiv_add_name").val('');
            $("#tb_data_adddiv_add_book").val('');
            $("#tb_data_adddiv_add_usernumber").val('');
            $("#tb_data_adddiv_add_begindate").val('');
            //结算date
            $("#tb_data_adddiv_add_jiesuandate").val('');
            //enddate
            $("#tb_data_adddiv_add_endddate").val('');
            $("#tb_data_adddiv_add_bankcardnumber").val('');
            $("#tb_data_adddiv_add_phone").val('');
            $("#tb_data_adddiv_add_lilv").val('');
            $("#tb_data_adddiv_add_cunkuantype").val('');
            $("#tb_data_adddiv_add_cunkuanmoney").val('');
            $("#tb_data_adddiv_add_beizhu").val('');
            $("#tb_data_adddiv_add_jiesuanzhouqi").val('');
            //结算清空
            $("#tb_data_name_jiesuan").val('');
            $("#tb_data_usernumber_jiesuan").val('');
            $("#tb_data_name_jiesuan").val('');
            $("#tb_data_begindate_jiesuan").val('');
            $("#tb_data_jiesuandate_jiesuan").val('');
            $("#tb_data_bankcardnumber_jiesuan").val('');
            $("#tb_data_phone_jiesuan").val('');
            $("#tb_data_lilv_jiesuan").val('');
            $("#tb_data_cunkuantype_jiesuan").val('');
            $("#tb_data_cunkuanmoney_jiesuan").val('');
            $("#tb_data_jiesuanzhouqi_jiesuan").val('');
            $("#tb_data_book_jiesuan").val('');
            $("#tb_data_enddate_jiesuan").val('');
            $("#tb_data_nowenddate_jiesuan").val('');//结算页面显示的 结算日期
            $("#tb_data_tianshu_jiesuan").val('');
            $("#tb_data_lixi_jiesuan").val('');
            $("#tb_data_beizhu_jiesuan").val('');
        } else {
            $("#tb_data_adddiv_add_name_huankuan").val('');
            $("#tb_data_adddiv_add_usernumber_huankuan").val('');
            $("#tb_data_adddiv_add_book_huankuan").val('');
            $("#tb_data_adddiv_add_phone_huankuan").val('');
            $("#tb_data_adddiv_add_begindate_huankuan").val('');
            $("#tb_data_adddiv_add_enddate_huankuan").val('');
            $("#tb_data_adddiv_add_carnumber_huankuan").val('');
            $("#tb_data_adddiv_add_daikuanmoney_huankuan").val('');
            $("#tb_data_adddiv_add_lilv_huankuan").val('');
            $("#tb_data_adddiv_add_shoufu_huankuan").val('');
            $("#tb_data_adddiv_add_beizhu_huankuan").val('');
            $("#tb_data_adddiv_add_shangcijiexidate_huankuan").val('');
            $("#tb_data_adddiv_add_shangcijiebendate_huankuan").val('');
            $("#tb_data_adddiv_add_yue_huankuan").val('');
            $("#tb_data_adddiv_add_danbao_huankuan").val('');
            $("#tb_data_adddiv_add_yuegong_huankuan").val('');
            $("#tb_data_adddiv_add_daikuantype_huankuan").val('');
            $("#department_select").val('');
            $("#tb_data_adddiv_add_lixi_huankuan").val('');


            $("#tb_data_name_jiesuan_huankuan").val('');
            $("#tb_data_usernumber_jiesuan_huankuan").val('');
            $("#tb_data_book_jiesuan_huankuan").val('');
            $("#tb_data_phone_jiesuan_huankuan").val('');
            $("#tb_data_carnumber_jiesuan_huankuan").val('');
            $("#tb_data_daikuanmoney_jiesuan_huankuan").val('');
            $("#tb_data_daikuantype_jiesuan_huankuan").val('');
            $("#tb_data_daikuanbegindate_jiesuan_huankuan").val('');
            $("#tb_data_lilv_jiesuan_huankuan").val('');
            $("#tb_data_yuegong_jiesuan_huankuan").val('');
            $("#tb_data_shoufu_jiesuan_huankuan").val('');
            $("#tb_data_lastjiexidate_jiesuan_huankuan").val('');
            $("#tb_data_lastjiebendate_jiesuan_huankuan").val('');
            $("#tb_data_yue_jiesuan_huankuan").val('');
            $("#tb_data_danbao_jiesuan_huankuan").val('');
            $("#tb_data_beizhu_jiesuan_huankuan").val('');
            $("#tb_data_yuhuanlixi_jiesuan_huankuan").val('');
            $("#tb_data_shihuanlixi_jiesuan_huankuan").val('');
            $("#tb_data_yuhuanbenjin_jiesuan_huankuan").val('');
            $("#tb_data_shihuanbenjin_jiesuan_huankuan").val('');
            $("#department_select_jiesuan").val('');
            $("#tb_data_lixi_jiesuan_huankuan").val('');

            $("#tb_data_name_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_usernumber_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_book_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_phone_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_carnumber_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_daikuanmoney_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_daikuantype_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_daikuanbegindate_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_lilv_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_yuegong_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_shoufu_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_lastjiexidate_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_lastjiebendate_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_yue_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_danbao_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_beizhu_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_yue_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_lixi_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_yuhuanlixi_jiesuan_huankuan_buhuan").val('');
            $("#tb_data_yuhuanbenjin_jiesuan_huankuan_buhuan").val('');


            renderForm();
            percentageDiv();
        }
    }
    //form清空---------------------------end---------------------------

    //chouben---------------------------start---------------------------
    function choubenlixi(cunkuandate, jiesuandate, cunkuanmoney, lilv, jiesuanzhouqi, departmentid, shijiday, day) {
        debugger
        ;
        if (departmentid == "1") { //借款利息计算
            if (cunkuandate == null) {
                return "";
            }
            if (jiesuandate == null) {
                return "";
            }
            if (cunkuanmoney == null) {
                return "";
            }
            if (lilv == null) {
                return "";
            }
            if (jiesuanzhouqi == null) {
                return "";
            }
            //没有结算过
            if (shijiday <= 2) {
                return '0.00'
            }
            <!-- day代表已存天数  大于结算周期的按结算周期天数算  -->
            //拿全部利息
            if ((parseInt((cunkuanmoney * lilv / jiesuanzhouqi * (shijiday - 2)) * 100) / 100).toFixed(2) < 0) {
                return 0.00;
            } else {
                return (parseInt((cunkuanmoney * lilv / jiesuanzhouqi * (shijiday - 2)) * 100) / 100).toFixed(2);
            }
        } else { //还款利息结算

        }

    }
    //chouben---------------------------end---------------------------


    //时间转换函数 yyyy-MM-dd hh:mm:ss-----------------------start-----------------------
    function showTime(tempDate) {
        if (tempDate == null) {
            return '';
        }
        var d = new Date(tempDate);
        var year = d.getFullYear();
        var month = d.getMonth();
        month++;
        var day = d.getDate();
        // var hours = d.getHours();
        //
        // var minutes = d.getMinutes();
        // var seconds = d.getSeconds();
        month = month < 10 ? "0" + month : month;
        day = day < 10 ? "0" + day : day;
        // hours = hours<10 ? "0"+hours:hours;
        // minutes = minutes<10 ? "0"+minutes:minutes;
        // seconds = seconds<10 ? "0"+seconds:seconds;

        //var time = year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
        var time = year + "-" + month + "-" + day;
        return time;
    }
    function showTime1(tempDate) {
        if (tempDate == null) {
            return '';
        }
        var d = new Date(tempDate);
        var year = d.getFullYear();
        var month = d.getMonth();
        month++;
        var day = d.getDate();
        var hours = d.getHours();

        var minutes = d.getMinutes();
        var seconds = d.getSeconds();
        month = month < 10 ? "0" + month : month;
        day = day < 10 ? "0" + day : day;
        hours = hours < 10 ? "0" + hours : hours;
        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        var time = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
        //var time = year + "-" + month + "-" + day;
        return time;
    }
    //时间转换函数 yyyy-MM-dd hh:mm:ss-----------------------end-----------------------

    //添加-----------------------------start------------------------------
    function addBean(department) {
        if (department == 1) {
            var lock = false;
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 1
                    , title: '添加'
                    , content: $('#tb_data_adddiv')
                    , maxmin: true
                    , area: ['700px', '600px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        if (!lock) {
                            lock = true;
                            //监听提交
                            var name = $("#tb_data_adddiv_add_name").val();
                            var usernumber = $("#tb_data_adddiv_add_usernumber").val();
                            var book = $("#tb_data_adddiv_add_book").val();
                            var begindate = $("#tb_data_adddiv_add_begindate").val();
                            var enddate = $("#tb_data_adddiv_add_jiesuandate").val();
                            var bankcarnumber = $("#tb_data_adddiv_add_bankcardnumber").val();
                            var phone = $("#tb_data_adddiv_add_phone").val();
                            var lilv = $("#tb_data_adddiv_add_lilv").val();
                            var cunkuantype = $("#tb_data_adddiv_add_cunkuantype").val();
                            var cunkuanmoney = $("#tb_data_adddiv_add_cunkuanmoney").val();
                            var beizhu = $("#tb_data_adddiv_add_beizhu").val();
                            var caozuoren = $("#caozuoren").val();
                            var jiesuanzhouqi = $("#tb_data_adddiv_add_jiesuanzhouqi").val();
                            var departmentid = $("#departmentid").val();
                            if (name == "") {
                                layer.msg("姓名不能为空");
                            } else if (begindate == "") {
                                layer.msg("请选择存款时间");
                            } else if (phone == "") {
                                layer.msg("联系方式不能为空");
                            } else if (lilv == "") {
                                layer.msg("利率不能为空");
                            } else if (cunkuanmoney == "") {
                                layer.msg("存款金额不能为空");
                            } else if (jiesuanzhouqi == "") {
                                layer.msg("结算周期不能为空");
                            } else {
                                $.ajax({
                                    url: '${ctx}/jiekuan/insert',
                                    type: 'post',
                                    dataTypep: 'json',
                                    data: {
                                        name: name,
                                        usernumber: usernumber,
                                        book: book,
                                        phone: phone,
                                        bankcardnumber: bankcarnumber,
                                        cunkuanmoney: cunkuanmoney,
                                        cunkuandate: begindate,
                                        lilv: lilv,
                                        cunkuantype: cunkuantype,
                                        jiesuandate: enddate,
                                        beizhu: beizhu,
                                        caozuoren: caozuoren,
                                        departmentid: departmentid,
                                        jiesuanzhouqi: jiesuanzhouqi,
                                        type: 0
                                    },
                                    success: function (res) {
                                        layer.msg(res.message);
                                        layui.table.reload('tb_data');
                                        layui.table.reload('tb_warning');
                                        reload(departmentid);
                                        layer.close(index); //关闭弹层
                                    }
                                });
                            }
                            return false;
                        }
                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        } else {
            // 还款添加--------------------------------------
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 1
                    , title: '添加'
                    , content: $('#tb_data_adddiv')
                    , maxmin: true
                    , area: ['800px', '650px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        //监听提交
                        var name = $("#tb_data_adddiv_add_name_huankuan").val();
                        var usernumber = $("#tb_data_adddiv_add_usernumber_huankuan").val();
                        var book = $("#tb_data_adddiv_add_book_huankuan").val();
                        var phone = $("#tb_data_adddiv_add_phone_huankuan").val();
                        var carnumber = $("#tb_data_adddiv_add_carnumber_huankuan").val();
                        var daikuanmoney = $("#tb_data_adddiv_add_daikuanmoney_huankuan").val();
                        var daikuantype = $("#tb_data_adddiv_add_daikuantype_huankuan").val();
                        var begindate = $("#tb_data_adddiv_add_begindate_huankuan").val();
                        //var enddate = $("#tb_data_adddiv_add_enddate_huankuan").val();
                        var lilv = $("#tb_data_adddiv_add_lilv_huankuan").val();
                        var yuegong = $("#tb_data_adddiv_add_yuegong_huankuan").val();
                        var shoufu = $("#tb_data_adddiv_add_shoufu_huankuan").val();
                        var lastjiexidate = $("#tb_data_adddiv_add_shangcijiexidate_huankuan").val();
                        var lastjiebendate = $("#tb_data_adddiv_add_shangcijiebendate_huankuan").val();
                        var yue = $("#tb_data_adddiv_add_yue_huankuan").val();
                        var danbao = $("#tb_data_adddiv_add_danbao_huankuan").val();
                        var beizhu = $("#tb_data_adddiv_add_beizhu_huankuan").val();
                        var lixi = $("#tb_data_adddiv_add_lixi_huankuan").val();
                        var caozuoren = $("#caozuoren").val();
                        var departmentid = $("#department_select").val();
                        if (name == "") {
                            layer.msg("姓名不能为空");
                        } else if (begindate == "") {
                            layer.msg("请选择放贷时间");
                        } else if (phone == "") {
                            layer.msg("联系方式不能为空");
                        } else if (lilv == "") {
                            layer.msg("利率不能为空");
                        } else if (daikuanmoney == "") {
                            layer.msg("存款金额不能为空");
                        } else if (departmentid == "") {
                            layer.msg("请选择车队");
                        } else {
                            $.ajax({
                                url: '${ctx}/huankuan/insert',
                                type: 'post',
                                dataTypep: 'json',
                                data: {
                                    name: name,
                                    usernumber: usernumber,
                                    book: book,
                                    phone: phone,
                                    carnumber: carnumber,
                                    daikuanmoney: daikuanmoney,
                                    daikuantype: daikuantype,
                                    daikuanbegindate: begindate,
                                    // daikuanenddate: enddate,
                                    lilv: lilv,
                                    yuegong: yuegong,
                                    jiexidate: lastjiexidate,
                                    jiebendate: lastjiebendate,
                                    shoufu: shoufu,
                                    yue: yue,
                                    beizhu: beizhu,
                                    danbao: danbao,
                                    caozuoren: caozuoren,
                                    departmentid: departmentid,
                                    type: 0,
                                    lixi: lixi
                                },
                                success: function (res) {
                                    layer.msg(res.message);
                                    layui.table.reload('tb_data');
                                    layui.table.reload('tb_warning');
                                    reload(departmentid);
                                    layer.close(index); //关闭弹层
                                }
                            });
                        }
                        return false;
                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        }
    }
    //添加  jiekuan---------------------------end--------------------------

    //查看---------------------start---------------------------
    function selectBean(data, departmentid) {
        if (departmentid == 1) {
            var id = data.id;
            layui.use('layer', function () {
                var layer = layui.layer;
                var table = layui.table;
                layer.open({
                    type: 1
                    , title: '查看'
                    , content: $("#chakan_div")
                    , maxmin: true
                    , area: ['1200px', '600px']
                    , success: function (layero, index) {
                        table.render({
                            elem: '#tb_chakan'
                            , url: '${ctx}/jiekuanliushui/selectByid'
                            , where: {
                                departmentid: departmentid,
                                jiekuanid: id
                            }
                            , totalRow: true
                            , cols: [[
                                {field: 'name', width: 90, title: '姓名'}
                                , {field: 'username', width: 120, title: '编号'}
                                , {field: 'book', width: 100, title: '账本'}
                                , {field: 'phone', title: '手机', width: 120} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                                , {field: 'banknumber', title: '银行卡号', width: 180}
                                , {field: 'cunkuanmoney', title: '存款金额', width: 100, sort: true}
                                , {field: 'cunkuantype', title: '存款方式', sort: true, width: 100}
                                , {field: 'strcunkuandate', title: '存款时间', sort: true, width: 120}
                                // , {
                                //     field: 'strjiesuandate', title: '结束日期', width: 120, sort: true
                                // }
                                , {field: 'jiesuanzhouqi', title: '结算周期', width: 90}
                                , {field: 'caozuoleixing', width: 120, title: '操作类型'}
                                , {field: 'qishu', title: '期数', width: 200}
                                , {field: 'lilv', title: '利率', width: 70}
                                , {field: 'lixi', title: '利息', width: 120, totalRow: true}
                                , {field: 'strcaozuodate', width: 200, title: '操作时间', sort: true}
                                , {field: 'beizhu', title: '备注', width: 120}
                                , {field: 'caozuoren', title: '经办人', width: 100}
                            ]]
                            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                                return {
                                    "code": res.state, //解析接口状态
                                    "msg": res.message, //解析提示文本
                                    "count": res.count, //解析数据长度
                                    "data": res.data //解析数据列表
                                };
                            }, response: {
                                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                            }
                            , page: true //开启分页
                            , limits: [5, 10, 15]
                            , limit: 5
                            , page: {
                                curr: 1
                            }
                            , toolbar: true
                        })
                    }
                });
            });
        } else {
            //查看流水
            var id = data.id;
            layui.use('layer', function () {
                var layer = layui.layer;
                var table = layui.table;
                layer.open({
                    type: 1
                    , title: '查看'
                    , content: $("#chakan_div")
                    , maxmin: true
                    , area: ['1200px', '600px']
                    , success: function (layero, index) {
                        table.render({
                            elem: '#tb_chakan'
                            , url: '${ctx}/huankuanliushui/selectByid'
                            , where: {
                                departmentid: departmentid,
                                huankuanid: id
                            }
                            , totalRow: true
                            , cols: [[
                                {field: 'name', width: 90, title: '姓名'}
                                , {field: 'namenumber', width: 120, title: '编号'}
                                , {field: 'book', width: 100, title: '账本'}
                                , {field: 'phone', title: '手机', width: 120} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                                , {field: 'carnumber', title: '车牌号', width: 100}
                                , {field: 'daikuantype', title: '贷款类型', width: 120}
                                , {field: 'daikuanmoney', title: '贷款金额', sort: true, width: 120}
                                , {field: 'strdaikuanbegindate', title: '开始时间', sort: true, width: 120}
                                // , {
                                //     field: 'strjiesuandate', title: '结束日期', width: 120, sort: true
                                // }
                                , {field: 'lilv', title: '利率', width: 80}
                                , {field: 'yuegong', width: 90, title: '月供'}
                                , {field: 'strjiebendate', title: '上次还本时间', width: 130}
                                , {field: 'strjiexidate', title: '上次还息时间', width: 130}
                                , {field: 'shoufu', title: '首付', width: 90}
                                , {field: 'yue', width: 90, title: '余额', sort: true}
                                , {field: 'beizhu', title: '备注', width: 100}
                                , {field: 'daobao', title: '担保', width: 100}
                                , {field: 'huankuantype', title: '还款类型', width: 100}
                                , {field: 'huanbenji', title: '还本金', width: 100, totalRow: true}
                                , {field: 'huanlixi', title: '还利息', width: 100, totalRow: true}
                                , {field: 'huankuantype', title: '还款类型', width: 100}
                                , {field: 'qishu', title: '期数', width: 180}
                                , {field: 'departmentname', title: '车队', width: 100}
                                , {field: 'lixi', title: '拖欠利息', width: 90}
                                , {field: 'strcaozuodate', title: '操作时间', width: 170}
                                , {field: 'caozuoren', title: '经办人', width: 90}
                            ]]
                            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                                return {
                                    "code": res.state, //解析接口状态
                                    "msg": res.message, //解析提示文本
                                    "count": res.count, //解析数据长度
                                    "data": res.data //解析数据列表
                                };
                            }, response: {
                                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                            }
                            , page: true //开启分页
                            , limits: [5, 10, 15]
                            , limit: 5
                            , page: {
                                curr: 1
                            }
                            , toolbar: true
                        })
                    }
                });
            });
            //查看流水end
        }
    }
    //查看----------------------end----------------------------


    function lixi(cunkuandate, jiesuandate, cunkuanmoney, lilv, jiesuanzhouqi, departmentid, shijiday, day, yujitianshu) {
        if (departmentid == "1") { //借款利息计算
            if (cunkuandate == null) {
                return "";
            }
            if (jiesuandate == null) {
                return "";
            }
            if (cunkuanmoney == null) {
                return "";
            }
            if (lilv == null) {
                return "";
            }
            if (jiesuanzhouqi == null) {
                return "";
            }
            //没有结算过
            if (shijiday <= 2) {
                return '0.00'
            }
            <!-- day代表已存天数  大于结算周期的按结算周期天数算  -->
            if (jiesuanzhouqi == 30) { //按季度取
                if (shijiday >= yujitianshu) {
                    //拿全部利息
                    if ((parseInt((cunkuanmoney * lilv / 30 * yujitianshu) * 100) / 100).toFixed(2) < 0) {
                        return 0.00;
                    } else {
                        return (parseInt((cunkuanmoney * lilv / 30 * yujitianshu) * 100) / 100).toFixed(2);
                    }
                } else if (shijiday < yujitianshu) {
                    if ((parseInt((cunkuanmoney * lilv / 30 * (shijiday)) * 100) / 100).toFixed(2) < 0) {
                        return 0.00;
                    } else {
                        return (parseInt((cunkuanmoney * lilv / 30 * (shijiday)) * 100) / 100).toFixed(2);
                    }
                }
            } else {// 按年计算
                if (shijiday >= yujitianshu) {
                    if ((parseInt(((cunkuanmoney * lilv / 360 * yujitianshu)) * 100) / 100).toFixed(2) < 0) {
                        return 0.00;
                    } else {
                        return (parseInt(((cunkuanmoney * lilv / 360 * yujitianshu)) * 100) / 100).toFixed(2);
                    }
                } else {
                    if ((parseInt(((cunkuanmoney * lilv / 360 * (yujitianshu)) / 2) * 100) / 100).toFixed(2) < 0) {
                        return 0.00;
                    } else {
                        return (parseInt(((cunkuanmoney * lilv / 360 * (yujitianshu)) / 2) * 100) / 100).toFixed(2);
                    }
                }
            }
        } else { //还款利息结算

        }

    }

    //结算---------------------------start---------------------------
    function jiesuan(data, departmentid, obj) {
        if (departmentid == 1) {
            var id = data.id;
            $("#tb_data_name_jiesuan").val(data.name);
            $("#tb_data_usernumber_jiesuan").val(data.usernumber);
            $("#tb_data_name_jiesuan").val(data.name);
            $("#tb_data_begindate_jiesuan").val(showTime(data.cunkuandate));
            $("#tb_data_jiesuandate_jiesuan").val(showTime(data.jiesuandate));
            $("#tb_data_bankcardnumber_jiesuan").val(data.bankcardnumber);
            $("#tb_data_phone_jiesuan").val(data.phone);
            $("#tb_data_lilv_jiesuan").val(data.lilv);
            $("#tb_data_cunkuantype_jiesuan").val(data.cunkuantype);
            $("#tb_data_cunkuanmoney_jiesuan").val(data.cunkuanmoney);
            $("#tb_data_jiesuanzhouqi_jiesuan").val(data.jiesuanzhouqi);
            $("#tb_data_book_jiesuan").val(data.book);
            $("#tb_data_enddate_jiesuan").val(showTime(data.enddate));
            var days;
            var jiesuantype;
            var jihuaday = data.day;
            var shijiday = data.shijiday;
            if (new Date() < data.jiesuandate) {
                $("#tb_data_nowenddate_jiesuan").val(showTime(showTime(new Date())));//结算页面显示的 结算日期
                $("#tb_data_tianshu_jiesuan").val(shijiday);
                if (data.enddate != null) {
                    $("#tb_data_lixi_jiesuan").val(lixi(data.enddate, showTime(new Date()), data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day, data.day));
                } else {
                    $("#tb_data_lixi_jiesuan").val(lixi(data.cunkuandate, showTime(new Date()), data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day, data.day));
                }
                if (data.jiesuanzhouqi == 30) {
                    caozuotype = "提前取利息";
                } else {
                    caozuotype = "提前取利息";
                }
            } else {
                $("#tb_data_nowenddate_jiesuan").val(showTime(data.jiesuandate));//结算页面显示的 结算日期
                $("#tb_data_tianshu_jiesuan").val(data.day);
                if (data.enddate != null) {
                    $("#tb_data_lixi_jiesuan").val(lixi(data.enddate, data.jiesuandate, data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day, data.day));
                } else {
                    $("#tb_data_lixi_jiesuan").val(lixi(data.cunkuandate, data.jiesuandate, data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day, data.day));
                }
                if (data.jiesuanzhouqi == 30) {
                    caozuotype = "取季度利息";
                } else {
                    caozuotype = "取年利息";
                }
            }
            layui.use('layer', function () {
                var layer = layui.layer;
                var lock = false;
                layer.open({
                    type: 1
                    , title: '取息'
                    , content: $('#tb_jiesuan')
                    , maxmin: true
                    , area: ['700px', '600px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        if (!lock) {
                            lock = true;
                            //监听提交
                            var name = $("#tb_data_name_jiesuan").val();
                            var usernumber = $("#tb_data_usernumber_jiesuan").val();
                            var book = $("#tb_data_book_jiesuan").val();
                            var begindate = $("#tb_data_begindate_jiesuan").val();
                            var jiesuandate = $("#tb_data_jiesuandate_jiesuan").val();
                            var lastenddate = $("#tb_data_enddate_jiesuan").val();
                            var nowenddate = $("#tb_data_nowenddate_jiesuan").val();
                            var bankcarnumber = $("#tb_data_bankcardnumber_jiesuan").val();
                            var phone = $("#tb_data_phone_jiesuan").val();
                            var lilv = $("#tb_data_lilv_jiesuan").val();
                            var cunkuantype = $("#tb_data_cunkuantype_jiesuan").val();
                            var cunkuanmoney = $("#tb_data_cunkuanmoney_jiesuan").val();
                            var beizhu = $("#tb_data_beizhu_jiesuan").val();
                            var caozuoren = $("#caozuoren").val();
                            var jiesuanzhouqi = $("#tb_data_jiesuanzhouqi_jiesuan").val();
                            var departmentid = $("#departmentid").val();
                            var lixi = $("#tb_data_lixi_jiesuan").val();
                            var days = $("#tb_data_tianshu_jiesuan").val();
                            if (name == "") {
                                layer.msg("姓名不能为空");
                            } else if (begindate == "") {
                                layer.msg("请选择存款时间");
                            } else if (jiesuandate == "") {
                                layer.msg("请选择结束时间");
                            } else if (phone == "") {
                                layer.msg("联系方式不能为空");
                            } else if (lilv == "") {
                                layer.msg("利率不能为空");
                            } else if (cunkuanmoney == "") {
                                layer.msg("存款金额不能为空");
                            } else if (jiesuanzhouqi == "") {
                                layer.msg("结算周期不能为空");
                            } else if (nowenddate == "") {
                                layer.msg("结算时间不能为空");
                            } else {
                                $.ajax({
                                    url: '${ctx}/jiekuanliushui/insert',
                                    type: 'post',
                                    dataTypep: 'json',
                                    data: {
                                        id: id,
                                        name: name,
                                        usernumber: usernumber,
                                        book: book,
                                        phone: phone,
                                        banknumber: bankcarnumber,
                                        cunkuanmoney: cunkuanmoney,
                                        cunkuandate: begindate,
                                        lilv: lilv,
                                        cunkuantype: cunkuantype,
                                        jiesuandate: jiesuandate,
                                        beizhu: beizhu,
                                        caozuoren: caozuoren,
                                        departmentid: departmentid,
                                        jiesuanzhouqi: jiesuanzhouqi,
                                        caozuoleixing: caozuotype,
                                        lixi: lixi,
                                        enddate: lastenddate,
                                        nowenddate: nowenddate
                                    },
                                    success: function (res) {
                                        layer.alert(res.message);
                                        layui.table.reload('tb_data');
                                        layui.table.reload('tb_warning');
                                        reload(departmentid);
                                        layer.close(index); //关闭弹层
                                    }
                                });
                            }
                            return false;
                        }

                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        } else {
            //还款--------还本
            $("#tb_data_shihuanlixi_jiesuan_huankuan").attr("disabled", true);
            $("#tb_data_shihuanbenjin_jiesuan_huankuan").attr("disabled", false);
            var id = data.id;
            $("#tb_data_name_jiesuan_huankuan").val(data.name);
            $("#tb_data_usernumber_jiesuan_huankuan").val(data.namenumber);
            $("#tb_data_book_jiesuan_huankuan").val(data.book);
            $("#tb_data_phone_jiesuan_huankuan").val(data.phone);
            $("#tb_data_carnumber_jiesuan_huankuan").val(data.carnumber);
            $("#tb_data_daikuanmoney_jiesuan_huankuan").val(data.daikuanmoney);
            $("#tb_data_daikuantype_jiesuan_huankuan").val(data.daikuantype);
            $("#tb_data_daikuanbegindate_jiesuan_huankuan").val(showTime(data.daikuanbegindate));
            $("#tb_data_lilv_jiesuan_huankuan").val(data.lilv);
            $("#tb_data_yuegong_jiesuan_huankuan").val(data.yuegong);
            $("#tb_data_shoufu_jiesuan_huankuan").val(data.shoufu);
            $("#tb_data_lastjiexidate_jiesuan_huankuan").val(showTime(data.jiexidate));
            $("#tb_data_lastjiebendate_jiesuan_huankuan").val(showTime(data.jiebendate));
            $("#tb_data_yue_jiesuan_huankuan").val(data.yue);
            $("#tb_data_danbao_jiesuan_huankuan").val(data.danbao);
            $("#tb_data_beizhu_jiesuan_huankuan").val(data.beizhu);
            $("#tb_data_yue_jiesuan_huankuan").val(data.yue);
            $("#tb_data_lixi_jiesuan_huankuan").val(data.lixi);
            $("#tb_data_yuhuanlixi_jiesuan_huankuan").val(data.havelixi);
            $("#tb_data_yuhuanbenjin_jiesuan_huankuan").val(data.yuegong);
            var caozuoleixing, huankuantype = "还本金";
            // <input type="text" class="layui-input" value="" id="tb_data_shihuanbenjin_jiesuan_huankuan" >
            // <label class="layui-form-label">实还本金</label>
            // <input type="text" class="layui-input" value="" id="tb_data_shiyuanbenjin_jiesuan_huankuan" >
            //select赋值
            var department = $("#department_select_jiesuan").find("option"); //获取select下拉框的所有值
            var departmentaaa = data.departmentid;
            for (var j = 1; j < department.length; j++) {
                if ($(department[j]).val() == data.departmentid) {
                    $(department[j]).prop("selected", "selected");
                    var s1 = 'dd[lay-value=' + departmentaaa + ']';
                    $(".layui-form-select").find('dl').find(s1).addClass('layui-this');
                    //$(department[j]).removeAttr("selected", "selected");
                    break;
                }
            }
            renderForm();
            layui.use('layer', function () {
                var layer = layui.layer;
                var lock = false;
                layer.open({
                    type: 1
                    , title: '还本金'
                    , content: $('#tb_jiesuan')
                    , maxmin: true
                    , area: ['800px', '650px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        if (!lock) {
                            lock = true;
                            //监听提交
                            var name = $("#tb_data_name_jiesuan_huankuan").val();
                            var usernumber = $("#tb_data_usernumber_jiesuan_huankuan").val();
                            var book = $("#tb_data_book_jiesuan_huankuan").val();
                            var phone = $("#tb_data_phone_jiesuan_huankuan").val();
                            var carnumber = $("#tb_data_carnumber_jiesuan_huankuan").val();
                            var daikuanmoney = $("#tb_data_daikuanmoney_jiesuan_huankuan").val();
                            var daikuantype = $("#tb_data_daikuantype_jiesuan_huankuan").val();
                            var daikuanbegindate = $("#tb_data_daikuanbegindate_jiesuan_huankuan").val();
                            var lilv = $("#tb_data_lilv_jiesuan_huankuan").val();
                            var yuegong = $("#tb_data_yuegong_jiesuan_huankuan").val();
                            var shoufu = $("#tb_data_shoufu_jiesuan_huankuan").val();
                            var lastjiexidate = $("#tb_data_lastjiexidate_jiesuan_huankuan").val();
                            var lastjiebendate = $("#tb_data_lastjiebendate_jiesuan_huankuan").val();
                            var yue = $("#tb_data_yue_jiesuan_huankuan").val();
                            var danbao = $("#tb_data_danbao_jiesuan_huankuan").val();
                            var beizhu = $("#tb_data_beizhu_jiesuan_huankuan").val();
                            var yuhuanlixi = $("#tb_data_yuhuanlixi_jiesuan_huankuan").val();
                            var yuhuanbenjin = $("#tb_data_yuhuanbenjin_jiesuan_huankuan").val();
                            var shihuanbenjin = $("#tb_data_shihuanbenjin_jiesuan_huankuan").val();
                            var caozuoren = $("#caozuoren").val();
                            var departmentid = $("#department_select_jiesuan").val();
                            var lixi = $("#tb_data_lixi_jiesuan_huankuan").val();
                            var daikuanenddate = showTime(data.daikuanenddate);
                            if (shihuanbenjin == "") {
                                layer.msg("实还本金不能为空");
                            }
                            $.ajax({
                                url: '${ctx}/huankuanliushui/insertbenjin',
                                type: 'post',
                                dataTypep: 'json',
                                data: {
                                    id: id,
                                    name: name,
                                    usernumber: usernumber,
                                    book: book,
                                    phone: phone,
                                    carnumber: carnumber,
                                    daikuanmoney: daikuanmoney,
                                    daikuantype: daikuantype,
                                    daikuanbegindate: daikuanbegindate,
                                    daikuanenddate: daikuanenddate,
                                    lilv: lilv,
                                    yuegong: yuegong,
                                    shoufu: shoufu,
                                    lastjiexidate: lastjiexidate,
                                    lastjiebendate: lastjiebendate,
                                    yue: yue,
                                    danbao: danbao,
                                    beizhu: beizhu,
                                    caozuoren: caozuoren,
                                    departmentid: departmentid,
                                    yuhuanlixi: yuhuanlixi,
                                    yuhuanbenjin: yuhuanbenjin,
                                    shihuanbenjin: shihuanbenjin,
                                    huankuantype: huankuantype,
                                    lixi: lixi,
                                    caozuoleixing: caozuoleixing
                                },
                                success: function (res) {
                                    layer.msg(res.message);
                                    layui.table.reload('tb_data');
                                    layui.table.reload('tb_warning');
                                    reload(departmentid);
                                    layer.close(index); //关闭弹层
                                }
                            });
                            return false;
                        }
                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
            //还款----还本---end
        }
    }
    //结算---------------------------end---------------------------

    //修改---------------------------start---------------------------
       function editBean(data, departmentid) {
        if (departmentid == 1) {
            var id = data.id;
            $("#tb_data_adddiv_add_name").val(data.name);
            $("#tb_data_adddiv_add_book").val(data.book);
            $("#tb_data_adddiv_add_usernumber").val(data.usernumber);
            $("#tb_data_adddiv_add_begindate").val(showTime(data.cunkuandate));
            $("#tb_data_adddiv_add_enddate").val(showTime(data.jiesuandate));
            $("#tb_data_adddiv_add_bankcardnumber").val(data.bankcardnumber);
            $("#tb_data_adddiv_add_phone").val(data.phone);
            $("#tb_data_adddiv_add_lilv").val(data.lilv);
            // $("#tb_data_adddiv_add_endddate").val(data.enddate);
            $("#tb_data_adddiv_add_cunkuantype").val(data.cunkuantype);
            $("#tb_data_adddiv_add_cunkuanmoney").val(data.cunkuanmoney);
            $("#tb_data_adddiv_add_beizhu").val(data.beizhu);
            $("#tb_data_adddiv_add_jiesuanzhouqi").val(data.jiesuanzhouqi);
            var lock = false;
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 1
                    , title: '修改'
                    , content: $('#tb_data_adddiv')
                    , maxmin: true
                    , area: ['700px', '600px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        if (!lock) {
                            lock = true;
                            //监听提交
                            var name = $("#tb_data_adddiv_add_name").val();
                            var usernumber = $("#tb_data_adddiv_add_usernumber").val();
                            var book = $("#tb_data_adddiv_add_book").val();
                            var begindate = $("#tb_data_adddiv_add_begindate").val();
                            var jiesuandate = showTime(data.jiesuandate);
                            var bankcarnumber = $("#tb_data_adddiv_add_bankcardnumber").val();
                            var phone = $("#tb_data_adddiv_add_phone").val();
                            var lilv = $("#tb_data_adddiv_add_lilv").val();
                            var cunkuantype = $("#tb_data_adddiv_add_cunkuantype").val();
                            var cunkuanmoney = $("#tb_data_adddiv_add_cunkuanmoney").val();
                            var beizhu = $("#tb_data_adddiv_add_beizhu").val();
                            var caozuoren = $("#caozuoren").val();
                            var jiesuanzhouqi = $("#tb_data_adddiv_add_jiesuanzhouqi").val();
                            var departmentid = $("#departmentid").val();
                            var endddate = showTime(data.enddate);
                            if (name == "") {
                                layer.msg("姓名不能为空");
                            } else if (begindate == "") {
                                layer.msg("请选择存款时间");
                            } else if (phone == "") {
                                layer.msg("联系方式不能为空");
                            } else if (lilv == "") {
                                layer.msg("利率不能为空");
                            } else if (cunkuanmoney == "") {
                                layer.msg("存款金额不能为空");
                            } else if (jiesuanzhouqi == "") {
                                layer.msg("结算周期不能为空");
                            } else {
                                $.ajax({
                                    url: '${ctx}/jiekuan/update',
                                    type: 'post',
                                    dataTypep: 'json',
                                    data: {
                                        id: id,
                                        name: name,
                                        usernumber: usernumber,
                                        book: book,
                                        phone: phone,
                                        bankcardnumber: bankcarnumber,
                                        cunkuanmoney: cunkuanmoney,
                                        cunkuandate: begindate,
                                        jiesuandate: jiesuandate,
                                        lilv: lilv,
                                        cunkuantype: cunkuantype,
                                        beizhu: beizhu,
                                        caozuoren: caozuoren,
                                        departmentid: departmentid,
                                        jiesuanzhouqi: jiesuanzhouqi,
                                        type: data.type,
                                        enddate: endddate
                                    },
                                    success: function (res) {
                                        layer.msg(res.message);
                                        layui.table.reload('tb_data');
                                        layui.table.reload('tb_warning');
                                        reload(departmentid);
                                        layer.close(index); //关闭弹层
                                        //   obj.del(); //删除对应行（tr）的DOM结构
                                    }
                                });
                            }
                            return false;
                        }
                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        } else {
            //还款修改
            debugger;
            var id = data.id;
            $("#tb_data_adddiv_add_name_huankuan").val(data.name);
            $("#tb_data_adddiv_add_usernumber_huankuan").val(data.namenumber);
            $("#tb_data_adddiv_add_book_huankuan").val(data.book);
            $("#tb_data_adddiv_add_phone_huankuan").val(data.phone);
            $("#tb_data_adddiv_add_carnumber_huankuan").val(data.carnumber);
            $("#tb_data_adddiv_add_daikuanmoney_huankuan").val(data.daikuanmoney);
            $("#tb_data_adddiv_add_begindate_huankuan").val(showTime(data.daikuanbegindate));
            $("#tb_data_adddiv_add_enddate_huankuan").val(showTime(data.daikuanenddate));
            $("#tb_data_adddiv_add_daikuantype_huankuan").val(data.daikuantype);
            $("#tb_data_adddiv_add_lilv_huankuan").val(data.lilv);
            $("#tb_data_adddiv_add_shoufu_huankuan").val(data.shoufu);
            $("#tb_data_adddiv_add_beizhu_huankuan").val(data.beizhu);
            $("#tb_data_adddiv_add_shangcijiexidate_huankuan").val(showTime(data.jiexidate));
            $("#tb_data_adddiv_add_shangcijiebendate_huankuan").val(showTime(data.jiebendate));
            $("#tb_data_adddiv_add_yue_huankuan").val(data.yue);
            $("#tb_data_adddiv_add_danbao_huankuan").val(data.danbao);
            $("#tb_data_adddiv_add_yuegong_huankuan").val(data.yuegong);
            $("#tb_data_adddiv_add_lixi_huankuan").val(data.lixi);
            //select赋值
            var department = $("#department_select").find("option"); //获取select下拉框的所有值
            var departmentaaa = data.departmentid;
            for (var j = 1; j < department.length; j++) {
                if ($(department[j]).val() == data.departmentid) {
                    $(department[j]).prop("selected", "selected");
                    var s1 = 'dd[lay-value=' + departmentaaa + ']';
                    $(".layui-form-select").find('dl').find(s1).addClass('layui-this');
                    //$(department[j]).removeAttr("selected", "selected");
                    break;
                }
            }
            renderForm();
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 1
                    , title: '修改'
                    , content: $('#tb_data_adddiv')
                    , maxmin: true
                    , area: ['800px', '700px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        //监听提交
                        var name = $("#tb_data_adddiv_add_name_huankuan").val();
                        var usernumber = $("#tb_data_adddiv_add_usernumber_huankuan").val();
                        var book = $("#tb_data_adddiv_add_book_huankuan").val();
                        var phone = $("#tb_data_adddiv_add_phone_huankuan").val();
                        var carnumber = $("#tb_data_adddiv_add_carnumber_huankuan").val();
                        var daikuanmoney = $("#tb_data_adddiv_add_daikuanmoney_huankuan").val();
                        var begindate = $("#tb_data_adddiv_add_begindate_huankuan").val();
                        var enddate = $("#tb_data_adddiv_add_enddate_huankuan").val();
                        var daikuantype = $("#tb_data_adddiv_add_daikuantype_huankuan").val();
                        var lilv = $("#tb_data_adddiv_add_lilv_huankuan").val();
                        var yuegong = $("#tb_data_adddiv_add_yuegong_huankuan").val();
                        var shoufu = $("#tb_data_adddiv_add_shoufu_huankuan").val();
                        var lastjiexidate = $("#tb_data_adddiv_add_shangcijiexidate_huankuan").val();
                        var lastjiebendate = $("#tb_data_adddiv_add_shangcijiebendate_huankuan").val();
                        var beizhu = $("#tb_data_adddiv_add_beizhu_huankuan").val();
                        var yue = $("#tb_data_adddiv_add_yue_huankuan").val();
                        var danbao = $("#tb_data_adddiv_add_danbao_huankuan").val();
                        var caozuoren = $("#caozuoren").val();
                        var departmentid = $("#department_select").val();
                        var lixi = $("#tb_data_adddiv_add_lixi_huankuan").val();
                        if (name == "") {
                            layer.msg("姓名不能为空");
                        } else if (begindate == "") {
                            layer.msg("请选择放贷时间");
                        } else if (phone == "") {
                            layer.msg("手机号不能为空");
                        } else {
                            $.ajax({
                                url: '${ctx}/huankuan/update',
                                type: 'post',
                                dataTypep: 'json',
                                data: {
                                    id: id,
                                    name: name,
                                    namenumber: usernumber,
                                    book: book,
                                    phone: phone,
                                    carnumber: carnumber,
                                    daikuantype: daikuantype,
                                    daikuanmoney: daikuanmoney,
                                    daikuanbegindate: begindate,
                                    daikuanenddate: enddate,
                                    lilv: lilv,
                                    yuegong: yuegong,
                                    jiexidate: lastjiexidate,
                                    jiebendate: lastjiebendate,
                                    shoufu: shoufu,
                                    yue: yue,
                                    beizhu: beizhu,
                                    danbao: danbao,
                                    caozuoren: caozuoren,
                                    departmentid: departmentid,
                                    type: 0,
                                    lixi: lixi
                                },
                                success: function (res) {
                                    layer.alert(res.message);
                                    layui.table.reload('tb_data');
                                    layui.table.reload('tb_warning');
                                    var departmentid = data.departmentid;
                                    //   var dd = $(".layui-form-select").find('dl').find('dd[lay-value=departmentid]').removeClass('layui-this'); //获取select下拉框的所有值
                                    for (var j = 1; j < department.length; j++) {
                                        if ($(department[j]).val() == data.departmentid) {
                                            // $(department[j]).attr("selected", "selected");
                                            $(department[j]).removeProp("selected", "selected");
                                            $(".layui-form-select").find('dl').find('dd[lay-value=' + departmentid + ']').removeClass('layui-this');
                                            break;
                                        }
                                    }
                                    reload(departmentid);
                                    layer.close(index); //关闭弹层
                                    // obj.del(); //删除对应行（tr）的DOM结构
                                }
                            });
                        }
                        return false;
                    }
                    , cancel: function (index, layero) {
                        debugger;
                        for (var j = 1; j < department.length; j++) {
                            if ($(department[j]).val() == data.departmentid) {
                                // $(department[j]).attr("selected", "selected");
                                $(department[j]).removeProp("selected", "selected");
                                break;
                            }
                        }
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        debugger;
                        for (var j = 1; j < department.length; j++) {
                            if ($(department[j]).val() == data.departmentid) {
                                // $(department[j]).attr("selected", "selected");
                                $(department[j]).removeProp("selected", "selected");
                                break;
                            }
                        }
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        }
    }
    //修改---------------------------end---------------------------

    //删除 -----------------------------start------------------------------
    function deleteBean(data, departmentid) {
        var caozuoren = $("#caozuoren").val();
        if (departmentid == 1) {
            var id = data.id;
            var lock = false;
            $.ajax({
                url: '${ctx}/jiekuan/delete',
                type: 'post',
                dataTypep: 'json',
                data: {
                    id: id,
                    type: 0,
                    caozuoren: caozuoren
                },
                success: function (res) {
                    if (!lock) {
                        lock = true;
                        layer.msg(res.message);
                        layui.table.reload('tb_data');
                        layui.table.reload('tb_warning');
                    }
                }
            });
        } else {
            var id = data.id;
            $.ajax({
                url: '${ctx}/huankuan/delete',
                type: 'post',
                dataTypep: 'json',
                data: {
                    id: id,
                    type: 0,
                    caozuoren: caozuoren
                },
                success: function (res) {
                    layer.msg(res.message);
                    layui.table.reload('tb_data');
                    layui.table.reload('tb_warning');
                }
            });
        }
    }
    //删除---------------------------end--------------------------

    //抽本---------------------------start---------------------------
    function chouben(data, departmentid, obj) {
        if (departmentid == 1) {
            var id = data.id;
            $("#tb_data_name_jiesuan").val(data.name);
            $("#tb_data_usernumber_jiesuan").val(data.usernumber);
            $("#tb_data_name_jiesuan").val(data.name);
            $("#tb_data_begindate_jiesuan").val(showTime(data.cunkuandate));
            $("#tb_data_jiesuandate_jiesuan").val(showTime(data.jiesuandate));
            $("#tb_data_bankcardnumber_jiesuan").val(data.bankcardnumber);
            $("#tb_data_phone_jiesuan").val(data.phone);
            $("#tb_data_lilv_jiesuan").val(data.lilv);
            $("#tb_data_cunkuantype_jiesuan").val(data.cunkuantype);
            $("#tb_data_cunkuanmoney_jiesuan").val(data.cunkuanmoney);
            $("#tb_data_jiesuanzhouqi_jiesuan").val(data.jiesuanzhouqi);
            $("#tb_data_book_jiesuan").val(data.book);
            $("#tb_data_enddate_jiesuan").val(showTime(data.enddate));
            var jihuadays = data.day;
            var jiesuantype;
            var shijidays = data.shijiday;
            if (data.jiesuanzhouqi == 30) { //按季度算
                $("#tb_data_nowenddate_jiesuan").val(showTime(showTime(new Date())));//抽本页面显示的 结算日期
                $("#tb_data_tianshu_jiesuan").val(data.shijiday);
                if (data.shijiday <= 2) {
                    $("#tb_data_lixi_jiesuan").val(0);
                    caozuotype = "抽本";
                } else {
                    $("#tb_data_lixi_jiesuan").val(choubenlixi(data.cunkuandate, new Date(), data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day));
                    caozuotype = "抽本";
                }
            } else {                            //年利息算
                $("#tb_data_nowenddate_jiesuan").val(showTime(showTime(new Date())));//抽本页面显示的 结算日期
                $("#tb_data_tianshu_jiesuan").val(data.shijiday);
                if (data.shijiday <= 2) {
                    $("#tb_data_lixi_jiesuan").val(0);
                    caozuotype = "抽本";
                } else {
                    $("#tb_data_lixi_jiesuan").val(choubenlixi(data.cunkuandate, new Date(), data.cunkuanmoney, data.lilv, data.jiesuanzhouqi, data.departmentid, data.shijiday, data.day));
                    caozuotype = "抽本";
                }
            }
            var lock = false;
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 1
                    , title: '抽本'
                    , content: $('#tb_jiesuan')
                    , maxmin: true
                    , area: ['700px', '600px']
                    , btn: ['确定', '取消']
                    , function(index, layero) {
                        //按钮【确定】的回调
                    }
                    , yes: function (index, layero) {
                        if (!lock) {
                            lock = true;
                            //监听提交
                            var name = $("#tb_data_name_jiesuan").val();
                            var usernumber = $("#tb_data_usernumber_jiesuan").val();
                            var book = $("#tb_data_book_jiesuan").val();
                            var begindate = $("#tb_data_begindate_jiesuan").val();
                            var jiesuandate = $("#tb_data_jiesuandate_jiesuan").val();
                            var lastenddate = $("#tb_data_enddate_jiesuan").val();
                            var nowenddate = $("#tb_data_nowenddate_jiesuan").val();
                            var bankcarnumber = $("#tb_data_bankcardnumber_jiesuan").val();
                            var phone = $("#tb_data_phone_jiesuan").val();
                            var lilv = $("#tb_data_lilv_jiesuan").val();
                            var cunkuantype = $("#tb_data_cunkuantype_jiesuan").val();
                            var cunkuanmoney = $("#tb_data_cunkuanmoney_jiesuan").val();
                            var beizhu = $("#tb_data_beizhu_jiesuan").val();
                            var caozuoren = $("#caozuoren").val();
                            var jiesuanzhouqi = $("#tb_data_jiesuanzhouqi_jiesuan").val();
                            var departmentid = $("#departmentid").val();
                            var lixi = $("#tb_data_lixi_jiesuan").val();
                            var days = $("#tb_data_tianshu_jiesuan").val();
                            if (name == "") {
                                layer.msg("姓名不能为空");
                            } else if (begindate == "") {
                                layer.msg("请选择存款时间");
                            } else if (jiesuandate == "") {
                                layer.msg("请选择结束时间");
                            } else if (lilv == "") {
                                layer.msg("利率不能为空");
                            } else if (cunkuanmoney == "") {
                                layer.msg("存款金额不能为空");
                            } else if (jiesuanzhouqi == "") {
                                layer.msg("结算周期不能为空");
                            } else if (nowenddate == "") {
                                layer.msg("结算时间不能为空");
                            } else {
                                $.ajax({
                                    url: '${ctx}/jiekuanliushui/insert',
                                    type: 'post',
                                    dataTypep: 'json',
                                    data: {
                                        id: id,
                                        name: name,
                                        usernumber: usernumber,
                                        book: book,
                                        phone: phone,
                                        banknumber: bankcarnumber,
                                        cunkuanmoney: cunkuanmoney,
                                        cunkuandate: begindate,
                                        lilv: lilv,
                                        cunkuantype: cunkuantype,
                                        jiesuandate: jiesuandate,
                                        beizhu: beizhu,
                                        caozuoren: caozuoren,
                                        departmentid: departmentid,
                                        jiesuanzhouqi: jiesuanzhouqi,
                                        caozuoleixing: caozuotype,
                                        lixi: lixi,
                                        enddate: lastenddate,
                                        nowenddate: nowenddate
                                    },
                                    success: function (res) {
                                        layer.alert(res.message);
                                        layui.table.reload('tb_data');
                                        layui.table.reload('tb_warning');
                                        reload(departmentid);
                                        layer.close(index); //关闭弹层
                                    }
                                });
                            }
                            return false;
                        }
                    }
                    , cancel: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                    , btn2: function (index, layero) {
                        reload(departmentid);
                        layer.close(index);
                    }
                });
            });
        }
    }
    //抽本---------------------------end---------------------------

    //还利息-------------------start---------------------------
    function huanxi(data, departmentid, obj) {
        //还款--------还本
        $("#tb_data_shihuanlixi_jiesuan_huankuan").attr("disabled", false);
        $("#tb_data_shihuanbenjin_jiesuan_huankuan").attr("disabled", true);
        var id = data.id;
        $("#tb_data_name_jiesuan_huankuan").val(data.name);
        $("#tb_data_usernumber_jiesuan_huankuan").val(data.namenumber);
        $("#tb_data_book_jiesuan_huankuan").val(data.book);
        $("#tb_data_phone_jiesuan_huankuan").val(data.phone);
        $("#tb_data_carnumber_jiesuan_huankuan").val(data.carnumber);
        $("#tb_data_daikuanmoney_jiesuan_huankuan").val(data.daikuanmoney);
        $("#tb_data_daikuantype_jiesuan_huankuan").val(data.daikuantype);
        $("#tb_data_daikuanbegindate_jiesuan_huankuan").val(showTime(data.daikuanbegindate));
        $("#tb_data_lilv_jiesuan_huankuan").val(data.lilv);
        $("#tb_data_yuegong_jiesuan_huankuan").val(data.yuegong);
        $("#tb_data_shoufu_jiesuan_huankuan").val(data.shoufu);
        $("#tb_data_lastjiexidate_jiesuan_huankuan").val(showTime(data.jiexidate));
        $("#tb_data_lastjiebendate_jiesuan_huankuan").val(showTime(data.jiebendate));
        $("#tb_data_yue_jiesuan_huankuan").val(data.yue);
        $("#tb_data_danbao_jiesuan_huankuan").val(data.danbao);
        $("#tb_data_beizhu_jiesuan_huankuan").val(data.beizhu);
        $("#tb_data_yue_jiesuan_huankuan").val(data.yue);
        $("#tb_data_lixi_jiesuan_huankuan").val(data.lixi);
        $("#tb_data_yuhuanlixi_jiesuan_huankuan").val(data.havelixi);
        $("#tb_data_yuhuanbenjin_jiesuan_huankuan").val(data.yuegong);
        var caozuoleixing, huankuantype = "还利息";
        // <input type="text" class="layui-input" value="" id="tb_data_shihuanbenjin_jiesuan_huankuan" >
        // <label class="layui-form-label">实还本金</label>
        // <input type="text" class="layui-input" value="" id="tb_data_shiyuanbenjin_jiesuan_huankuan" >
        //select赋值
        var department = $("#department_select_jiesuan").find("option"); //获取select下拉框的所有值
        var departmentaaa = data.departmentid;
        for (var j = 1; j < department.length; j++) {
            if ($(department[j]).val() == data.departmentid) {
                $(department[j]).prop("selected", "selected");
                var s1 = 'dd[lay-value=' + departmentaaa + ']';
                $(".layui-form-select").find('dl').find(s1).addClass('layui-this');
                //$(department[j]).removeAttr("selected", "selected");
                break;
            }
        }
        renderForm();
        layui.use('layer', function () {
            var layer = layui.layer;
            var lock = false;
            layer.open({
                type: 1
                , title: '还利息'
                , content: $('#tb_jiesuan')
                , maxmin: true
                , area: ['800px', '650px']
                , btn: ['确定', '取消']
                , function(index, layero) {
                    //按钮【确定】的回调
                }
                , yes: function (index, layero) {
                    if (!lock) {
                        lock = true;
                        //监听提交
                        var name = $("#tb_data_name_jiesuan_huankuan").val();
                        var usernumber = $("#tb_data_usernumber_jiesuan_huankuan").val();
                        var book = $("#tb_data_book_jiesuan_huankuan").val();
                        var phone = $("#tb_data_phone_jiesuan_huankuan").val();
                        var carnumber = $("#tb_data_carnumber_jiesuan_huankuan").val();
                        var daikuanmoney = $("#tb_data_daikuanmoney_jiesuan_huankuan").val();
                        var daikuantype = $("#tb_data_daikuantype_jiesuan_huankuan").val();
                        var daikuanbegindate = $("#tb_data_daikuanbegindate_jiesuan_huankuan").val();
                        var lilv = $("#tb_data_lilv_jiesuan_huankuan").val();
                        var yuegong = $("#tb_data_yuegong_jiesuan_huankuan").val();
                        var shoufu = $("#tb_data_shoufu_jiesuan_huankuan").val();
                        var lastjiexidate = $("#tb_data_lastjiexidate_jiesuan_huankuan").val();
                        var lastjiebendate = $("#tb_data_lastjiebendate_jiesuan_huankuan").val();
                        var yue = $("#tb_data_yue_jiesuan_huankuan").val();
                        var danbao = $("#tb_data_danbao_jiesuan_huankuan").val();
                        var beizhu = $("#tb_data_beizhu_jiesuan_huankuan").val();
                        var yuhuanlixi = $("#tb_data_yuhuanlixi_jiesuan_huankuan").val();
                        var yuhuanbenjin = $("#tb_data_yuhuanbenjin_jiesuan_huankuan").val();
                        var shihuanlixi = $("#tb_data_shihuanlixi_jiesuan_huankuan").val();
                        var caozuoren = $("#caozuoren").val();
                        var departmentid = $("#department_select_jiesuan").val();
                        var lixi = $("#tb_data_lixi_jiesuan_huankuan").val();
                        var daikuanenddate = showTime(data.daikuanenddate);
                        if (shihuanlixi == "") {
                            layer.msg("实还利息不能为空");
                        }
                        if (shihuanlixi > yuhuanlixi) {
                            layer.msg("实还利息不能大于应还利息");
                        }
                        $.ajax({
                            url: '${ctx}/huankuanliushui/insertlixi',
                            type: 'post',
                            dataTypep: 'json',
                            data: {
                                id: id,
                                name: name,
                                usernumber: usernumber,
                                book: book,
                                phone: phone,
                                carnumber: carnumber,
                                daikuanmoney: daikuanmoney,
                                daikuantype: daikuantype,
                                daikuanbegindate: daikuanbegindate,
                                daikuanenddate: daikuanenddate,
                                lilv: lilv,
                                yuegong: yuegong,
                                shoufu: shoufu,
                                lastjiexidate: lastjiexidate,
                                lastjiebendate: lastjiebendate,
                                yue: yue,
                                danbao: danbao,
                                beizhu: beizhu,
                                caozuoren: caozuoren,
                                departmentid: departmentid,
                                yuhuanlixi: yuhuanlixi,
                                yuhuanbenjin: yuhuanbenjin,
                                shihuanlixi: shihuanlixi,
                                huankuantype: huankuantype,
                                lixi: lixi,
                                caozuoleixing: caozuoleixing
                            },
                            success: function (res) {
                                layer.msg(res.message);
                                layui.table.reload('tb_data');
                                layui.table.reload('tb_warning');
                                reload(departmentid);
                                layer.close(index); //关闭弹层
                            }
                        });
                        return false;
                    }
                }
                , cancel: function (index, layero) {
                    reload(departmentid);
                    layer.close(index);
                }
                , btn2: function (index, layero) {
                    reload(departmentid);
                    layer.close(index);
                }
            });
        });
    }
    //还利息-------------------end---------------------------

    //补还-------------------start---------------------------
    function buhuan(data, departmentid, obj){
        //     <label class="layui-form-label">还款日期</label>
        //     <div class="layui-input-inline">
        //     <input type="text" class="layui-input" value="" id="tb_data_shihuandate_jiesuan_huankuan">
        // //还款--------还本
        var id = data.id;
        $("#tb_data_name_jiesuan_huankuan_buhuan").val(data.name);
        $("#tb_data_usernumber_jiesuan_huankuan_buhuan").val(data.namenumber);
        $("#tb_data_book_jiesuan_huankuan_buhuan").val(data.book);
        $("#tb_data_phone_jiesuan_huankuan_buhuan").val(data.phone);
        $("#tb_data_carnumber_jiesuan_huankuan_buhuan").val(data.carnumber);
        $("#tb_data_daikuanmoney_jiesuan_huankuan_buhuan").val(data.daikuanmoney);
        $("#tb_data_daikuantype_jiesuan_huankuan_buhuan").val(data.daikuantype);
        $("#tb_data_daikuanbegindate_jiesuan_huankuan_buhuan").val(showTime(data.daikuanbegindate));
        $("#tb_data_lilv_jiesuan_huankuan_buhuan").val(data.lilv);
        $("#tb_data_yuegong_jiesuan_huankuan_buhuan").val(data.yuegong);
        $("#tb_data_shoufu_jiesuan_huankuan_buhuan").val(data.shoufu);
        $("#tb_data_lastjiexidate_jiesuan_huankuan_buhuan").val(showTime(data.jiexidate));
        $("#tb_data_lastjiebendate_jiesuan_huankuan_buhuan").val(showTime(data.jiebendate));
        $("#tb_data_yue_jiesuan_huankuan_buhuan").val(data.yue);
        $("#tb_data_danbao_jiesuan_huankuan_buhuan").val(data.danbao);
        $("#tb_data_beizhu_jiesuan_huankuan_buhuan").val(data.beizhu);
        $("#tb_data_yue_jiesuan_huankuan_buhuan").val(data.yue);
        $("#tb_data_lixi_jiesuan_huankuan_buhuan").val(data.lixi);
        $("#tb_data_yuhuanlixi_jiesuan_huankuan_buhuan").val(data.havelixi);
        $("#tb_data_yuhuanbenjin_jiesuan_huankuan_buhuan").val(data.yuegong);
        var caozuoleixing, huankuantype = "补录数据";
        // <input type="text" class="layui-input" value="" id="tb_data_shihuanbenjin_jiesuan_huankuan" >
        // <label class="layui-form-label">实还本金</label>
        // <input type="text" class="layui-input" value="" id="tb_data_shiyuanbenjin_jiesuan_huankuan" >
        //select赋值
        var department = $("#department_select_jiesuan_buhuan").find("option"); //获取select下拉框的所有值
        var departmentaaa = data.departmentid;
        for (var j = 1; j < department.length; j++) {
            if ($(department[j]).val() == data.departmentid) {
                $(department[j]).prop("selected", "selected");
                var s1 = 'dd[lay-value=' + departmentaaa + ']';
                $(".layui-form-select").find('dl').find(s1).addClass('layui-this');
                //$(department[j]).removeAttr("selected", "selected");
                break;
            }
        }
        renderForm();
        layui.use('layer', function () {
            var layer = layui.layer;
            var lock = false;
            layer.open({
                type: 1
                , title: '补录数据'
                , content: $('#tb_jiesuan_tiqian')
                , maxmin: true
                , area: ['650px', '450px']
                , btn: ['确定', '取消']
                , function(index, layero) {
                    //按钮【确定】的回调
                }
                , yes: function (index, layero) {
                    if (!lock) {
                        lock = true;
                        //监听提交
                        var name = $("#tb_data_name_jiesuan_huankuan_buhuan").val();
                        var usernumber = $("#tb_data_usernumber_jiesuan_huankuan_buhuan").val();
                        var book = $("#tb_data_book_jiesuan_huankuan_buhuan").val();
                        var phone = $("#tb_data_phone_jiesuan_huankuan_buhuan").val();
                        var carnumber = $("#tb_data_carnumber_jiesuan_huankuan_buhuan").val();
                        var daikuanmoney = $("#tb_data_daikuanmoney_jiesuan_huankuan_buhuan").val();
                        var daikuantype = $("#tb_data_daikuantype_jiesuan_huankuan_buhuan").val();
                        var daikuanbegindate = $("#tb_data_daikuanbegindate_jiesuan_huankuan_buhuan").val();
                        var lilv = $("#tb_data_lilv_jiesuan_huankuan_buhuan").val();
                        var yuegong = $("#tb_data_yuegong_jiesuan_huankuan_buhuan").val();
                        var shoufu = $("#tb_data_shoufu_jiesuan_huankuan_buhuan").val();
                        var lastjiexidate = $("#tb_data_lastjiexidate_jiesuan_huankuan_buhuan").val();
                        var lastjiebendate = $("#tb_data_lastjiebendate_jiesuan_huankuan_buhuan").val();
                        var yue = $("#tb_data_yue_jiesuan_huankuan_buhuan").val();
                        var danbao = $("#tb_data_danbao_jiesuan_huankuan_buhuan").val();
                        var beizhu = $("#tb_data_beizhu_jiesuan_huankuan_buhuan").val();
                        var yuhuanlixi = $("#tb_data_yuhuanlixi_jiesuan_huankuan_buhuan").val();
                        var yuhuanbenjin = $("#tb_data_yuhuanbenjin_jiesuan_huankuan_buhuan").val();
                        var shihuanjine = $("#tb_data_shihuanjine_jiesuan_huankuan").val();
                        var caozuoren = $("#caozuoren").val();
                        var shihuandate=$("#tb_data_shihuandate_jiesuan_huankuan").val();
                        var departmentid = $("#department_select_jiesuan_buhuan").val();
                        var lixi = $("#tb_data_lixi_jiesuan_huankuan_buhuan").val();
                        var daikuanenddate = showTime(data.daikuanenddate);
                        if (shihuanjine == "") {
                            layer.msg("实还本金不能为空");
                        }
                        $.ajax({
                            url: '${ctx}/huankuanliushui/buhuan',
                            type: 'post',
                            dataTypep: 'json',
                            data: {
                                id: id,
                                name: name,
                                usernumber: usernumber,
                                book: book,
                                phone: phone,
                                carnumber: carnumber,
                                daikuanmoney: daikuanmoney,
                                daikuantype: daikuantype,
                                daikuanbegindate: daikuanbegindate,
                                daikuanenddate: daikuanenddate,
                                lilv: lilv,
                                yuegong: yuegong,
                                shoufu: shoufu,
                                lastjiexidate: lastjiexidate,
                                lastjiebendate: lastjiebendate,
                                yue: yue,
                                danbao: danbao,
                                beizhu: beizhu,
                                caozuoren: caozuoren,
                                departmentid: departmentid,
                                yuhuanlixi: yuhuanlixi,
                                yuhuanbenjin: yuhuanbenjin,
                                shihuanjine: shihuanjine,
                                shihuandate:shihuandate,
                                huankuantype: huankuantype,
                                lixi: lixi,
                                caozuoleixing: caozuoleixing
                            },
                            success: function (res) {
                                layer.msg(res.message);
                                layui.table.reload('tb_data');
                                layui.table.reload('tb_warning');
                                reload(departmentid);
                                layer.close(index); //关闭弹层
                            }
                        });
                        return false;
                    }
                }
                , cancel: function (index, layero) {
                    reload(departmentid);
                    layer.close(index);
                }
                , btn2: function (index, layero) {
                    reload(departmentid);
                    layer.close(index);
                }
            });
        });
    }
    //补还-------------------start---------------------------
</script>
</body>
</html>
